Questions tagged [game-of-fifteen]

Game of Fifteen, one of the assignments in Problem Set 3

Filter by
Sorted by
Tagged with
1
vote
2answers
50 views

My code is swapping “1”, “2” even if i have written code only for swapping “if even.”

This is my init function, please check and suggest: void init(void) { int size= d*d; for (int i=0;i<d;i++) { for (int j=0;j<d;j++) { board[i][j]=size-1; ...
0
votes
1answer
68 views

My game of fifteen doesn't work

void init(void) { // TODO int fill = ((d * d) - 1); int brow = d; //fill entire grid except the bottom for(int i = 1; i <= d; i ++) { for(int j = 1; j <= d; j ++)...
0
votes
1answer
28 views

Move function only moving underscore to the left and not replacing?

My move function is only moving right and also not replacing my tile with the switched tile. The relevant code looks like: bool move(int tile) { for (int row=0; row < d; row++ ) { ...
0
votes
1answer
33 views

pset3/fifteen/issue with board

I have an issue making my board in fifteen, i think im doing well but it shows something i can't explain. Can anyone help me? why my board numbers shudenly do this weird thing: My code: void init(...
0
votes
1answer
51 views

pset3 game of fifteen won() function does not work

Just in case, I'll put the code of the other functions, but they, like, are successfully tested. void init(void) { int value = d*d - 1, c; for(int i = 0; i < d; i++) { for(int ...
0
votes
1answer
26 views

Pset3_Fifteen_Won()

bool won(void) { // TODO for(int r=0;r<d;r++) { for(int c=0;c<d;c++) { if(c==r==(d-1)) { if(board[r][c] != 0) { return true; ...
0
votes
1answer
35 views

Game of fifteen is is somewhat randomly printing extra lines of numbers and deeming moves illegal

Game of fifteen is 1) printing an extra line each time a move is labeled illegal and 2) somewhat randomly labeling moves illegal (e.g. it will swap to the left once but not twice, and up/down etc. ...
1
vote
4answers
458 views

Pset3 fifteen.c - Move function allows invalid moves

To implement the move() function I divided it into three functions, one to find the tile inputted by the user, one to check if the move is legal, and one to actually move the tiles. At first it looked ...
0
votes
1answer
57 views

pset3 check receives standard error from init()

The game compiles and runs, passing all the other tests in check50 when entered manually, but on the step for testing init, check50 fails. Here's the check50 output: https://sandbox.cs50.net/checks/...
0
votes
1answer
67 views

Pset3 Move Function “Illegal Move”

my code is notifying me with "Illegal Move" every time I test it. I was wondering if someone can help figure out what is wrong with my code? bool move(int tile) { // TODO int i, j; int swap; //rows ...
0
votes
1answer
83 views

CS50 Pset3 “Fifteen” Works but doesn't pass Check50

My code for pset3 "fifteen" works perfectly when I play it—board sizes fit, goes in descending order, blank space prints as a 0 etc. etc. but for some reason, it won't pass any check50 checks past "...
0
votes
2answers
383 views

Check50, Game of Fifteen. Timed out while waiting for “Illegal move”

I've finished working on my pset3 game of fifteen. After consulting Check50, it keeps telling me that: timed out while waiting for "Illegal move." Can someone explain this to me? Don't know what to do....
0
votes
1answer
205 views

Have I got the right idea? Pset3/Fifteen/Move

This is my code for identifying the blank tile: bool move(int tile) { int temp; int didSwap; int blankTile = 0; // search for blank tile for(int row = 0; row < d; row++) ...
0
votes
1answer
97 views

game of fiteen doubts in code and in check50

have a look at my game of fifteen code at: http://pastebin.com/gpZnkTPp it is showing errors in check50 , but i don't know what's wrong with my code check50 2015.fall.pset3.fifteen fifteen.c :) ...
0
votes
2answers
90 views

Pset3 Game of Fifteen - Zeroes

void init(void) { int count = d*d-1; for(int i=0; i < d; i++) { for(int j = 0;j< d;j++) { board[i][j] = count; count--; } } //if even number swap 1 and 2 if(d%2==1) ...
0
votes
1answer
217 views

Why won't my nested for-loops compile?

I'm trying to use nested for loops in the "init" part of Game of Fifteen and can't figure out why my code won't compile. Here's the code: for (i = 0; i < d; i++) { for (j = 0; j < d; j++) ...
0
votes
1answer
155 views

Game of Fifteen PSET3: CS50 - won function and check50

Hi I have yet another question about game of fifteen. I seem to have implemented by 'won' function correctly. Before this check50 was running and I was getting a pass for everything, excluding the '...
0
votes
3answers
131 views

FIFTEEN works perfectly but doesn't pass Check50

My program works perfectly. Though, my Check50 says that my program only compiles and runs, nothing else. I think this has to do with my draw function, but I can't spot the mistake Can anyone help me ...
0
votes
1answer
276 views

(pset3: fifteen) my code work on 4x4.txt but not on 3x3.txt?

I am getting correct output for 4x4.txt but not for 3x3.txt. I can't understand what went wrong. I have downloaded both the file as I am not using appliance. Can anyone check weather my 3x3.txt file ...
0
votes
1answer
119 views

Init fails to intialize any of the boards for fifteen on check50

I'm receiving a segementation fault with the code below. I've played with the code a little bit. I'm assuming there are problems in the move and won functions as well, but I'm unable to check them, ...
0
votes
1answer
98 views

Values for tile locations are 0 in gdb

I'm not getting whats going wrong with my move and draw functions. When I trace the program through gdb I'm getting the 0 values for tile locations.
0
votes
1answer
102 views

game of fiteen shows errors in check50

guys my game of fifteen is showing errors in check50 please help here's my pastebin link http://pastebin.com/TgA030A5 check50 2015.fall.pset3.fifteen fifteen.c :) fifteen.c exists :) fifteen.c ...
0
votes
1answer
166 views

Game of fifteen: everything works perfect until winning move breaks game

I've gotten pretty much everything working in fifteen. The tiles move correctly, the redraw works with a board of any size, et cetera. So I pasted in the ./fifteen 3 < ~cs50/pset3/3x3.txt the pset ...
0
votes
1answer
103 views

Game Of Fifteen Won Function

my won function for Game of Fifteen does not exit. check50 says it timed out waiting for the program to exit. My other functions for game of fifteen seem fine. Help would be appreciated! bool won(...
0
votes
1answer
14 views

Move function do not working

I cant understend why, but my move function does not work properly. It looks correct to y mind. But no Can you please chck what's wrong? bool move(int tile) { if(tile > d*d-1 || tile <= 0) ...
3
votes
2answers
28k views

How to solve “control may reach end of non void function” error

When I try to compile my code, I get an error message that says "control may reach end of non void function." What does this message mean and how can I avoid this error? Here is the function that's ...
0
votes
1answer
39 views

CS50 AP Game of Fifteen

I'm currently getting an error for "make sure game is winnable" but my program works with ./fifteen 3 < ~cs50/unit3/3x3.txt Here is my error log: :) fifteen.c exists. :) fifteen.c compiles. :) ...
0
votes
1answer
22 views

fifteen won function timing out

So I have looked and seen very similar (non-working) solutions, but my code is very slightly different from what I've seen here, and the answers that I've seen haven't really helped me. I'm a complete ...
1
vote
1answer
37 views

pset 3 fifteen - check50 failure last 3x3, 4x4

I was going to check my solution to pset3 fifteen with check50 while I received two failure errors on the console (on the last 3x3 and 4x4 checks). :) fifteen.c exists. :) fifteen.c compiles. :) ...
0
votes
1answer
40 views

Won() function not working and gives error

This error is shown while compiling(error is pointed to the last closing bracket of won function)- error: control may reach end of non-void function [-Werror,-Wreturn-type]. here is my code for won()...
0
votes
1answer
47 views

allmost done, pset3 fifteen 4x4 doesnt work

I can not fix the won function. Itso almost complete but the 4x4 is not winnable... please help!
0
votes
1answer
23 views

pset3 control may reach end error [duplicate]

this is my code, iv seen the other possibilities of getting this error and corrected them but i still get it. bool move(int tile) { int a = board[d][d]; for(int i =0; i<d;i++) { for( int j=...
0
votes
2answers
105 views

Won()- Pset 3- Game of Fifteen

I'm having trouble seeing where my logic is going wrong with my won() function for Game of Fifteen (Pset 3). For example looking at my for loop, let's say d=4, i = 2, j = 1. Then board[i][j] = board[...
0
votes
1answer
49 views

PSET3: Every move is ilegal, no matter what

I'm currently working on the move function that's in the game of fifteen and every single move is illegal even though my logic seems correct (at least to me), but it keeps outputting illegal move and ...
0
votes
1answer
67 views

Having trouble with board[i][j] = {8,7,6,5,4,3,2,1,0};

First int board[i][j] = { (board_num - j) }; Will not work and I don't know why. Here is an example of the board below. 012 0 876 1 543 2 210 I think it should take 8-0, 8 -1, 8-2, 8-3, 8-4, 8-4, ...
0
votes
1answer
35 views

Game of Fifteen Draw function outputting only zeros

I am currently trying to solve a bug that prevents me from printing my wanted values. When I initialize the board and try to assign the value it appears to assign only zeros from the for loops even ...
0
votes
1answer
43 views

Game Of Fifteen Won function does not exit

I opened a question about game of fifteen before and took some suggestions, now I am trying to figure out why it will not exit. check50 says it waits for it to exit when seeing if it is winnable or ...
0
votes
1answer
162 views

Game Of Fifteen Moving

Ok, so I took some tips from another post I made and I have improved my code, but I still cannot swap my tiles. Also, it appears that all tile moves are legal and none of them print "illegal" even ...
0
votes
1answer
24 views

Game Of Fifteen won't print moves

I have completed functions init; draw; and move. My gameboard draws, but does not draw the move. My logic in move works (I hope) since it returns correct feedback (ie "illegal move" when it is ...
0
votes
1answer
62 views

CS50 pset 3 game of fifteen. Won function not working

Not quite sure why my won function is not working. Any tips would be appreciated. bool won(void) { // declare win variable int win = 1; // iterate through board for (int i = 0; i &...
0
votes
0answers
56 views

pset3 Game of fifteen -make

it is not swapping the values but instead copying it ...pls someone tell me where the problem lies in my code... //move function bool move(int tile) { void swap(int *a,int *b); //check the ...
0
votes
1answer
75 views

A wierd error in won function (fifteen)

when I run Check50 my program passes all the tests except one, the terminal spits out this weird cryptic error :( 3x3 board: make sure game is winnable expected "Tile to move:", not "[2J[0;0H1-2-...
0
votes
1answer
261 views

Timed out while trying to exit (Fifteen)

Whenever I run Check50 my program passes all the tests except the last two, the terminal spits out :( 3x3 board: make sure game is winnable timed out while waiting for program to exit :( 4x4 ...
0
votes
1answer
28 views

PSET3 Game of Fifteen init for loop stops unexpected

So I am stuck at initializing the board. my for loop is doing what it should but it stops when it is not actually done. The board I initialize is made of the dimensions d * d and should start left to ...
0
votes
1answer
585 views

Pset 3 - Check 50 error for fifteen

The code for pset 3 fiftenn is running fine when i enter different values of d and is getting completed as well. But on check 50 getting the following set of errors. Any help here would be ...
0
votes
1answer
55 views

pset3 game of fifteen won()

The won() function, which I thought was pretty straightforward, initially gave me some trouble. I had it trying to evaluate the if statement seen below in a loop that iterated over each position of ...
0
votes
1answer
91 views

Game of Fifteen move function doesn't work properly [duplicate]

Some tiles move just fine but in other cases the tiles become a lowercase too, leaving my game with 2 or more empty tiles. I cant figure out why my code works for some moves, but not all of the moves! ...
0
votes
1answer
61 views

PSET3 Game Of Fifteen tiles not swapping! (no illegal function but no change in board)

My game of fifteen is somehow still not working. here is the code for move() bool move(int tile) { // TODO // find location of specified tile using linear search //find tile location in nice ...
0
votes
1answer
56 views

PSET3 'Illegal Move" coming up for legal moves as well! Almost done!

I have finished with Pset3 except for a tiny little bug. every move is somehow an Illegal Move. here's my code. bool move(int tile) { // TODO // find location of specified tile using linear search ...
0
votes
1answer
41 views

cs50 game of fiteen move does not move am quite stuck

Thank you both for your help. I have tried to change my code but it still does not work. If you can give me one or two more hints, would be grateful. Thanks. bool move(int tile) { if (tile > d*...

1
2 3 4 5