Questions tagged [game-of-fifteen]

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

0
votes
1answer
9 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) ...
0
votes
1answer
14 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
0answers
18 views

Pset fifteen - check wrong although solution is the same [duplicate]

When I run the check50 command I get multiple failure messages: 3x3 board: move blank up twice 3x3 board: move up-up-left-down-down-left-up-up-right-down-down-right 3x3 board: make sure none of 2, 4, ...
0
votes
1answer
20 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
19 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
36 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
42 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
68 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
1answer
22 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
96 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
44 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
30 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
64 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
42 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
77 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
61 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
61 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
55 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
72 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
234 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
566 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
47 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
51 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
2answers
376 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
59 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
40 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*...
0
votes
1answer
26 views

Why can an integer data type be declared with board[DIM_MAX][DIM_MAX]

Just a quick conceptual question here: in pset3 fifteen, line 27 of the given code shows: int board[DIM_MAX][DIM_MAX] I just want to check my understanding here- board has not yet been declared as a ...
0
votes
1answer
46 views

check50 error on PSET3 Game of Fifteen

I used the cs50 sample 3x3.txt and 4x4.txt to check my code. I saw 'ftw' output for both cases so it works. I have checked my move() function manually and it works but when I use check50 to check for ...
0
votes
1answer
34 views

Pset 3 Game of Fifteen Won Function

I've used check50 to confirm that everything is working except for my won function. I've tried many different variations of the below code, and I'm not sure why it's not working. bool won(void) { if (...
0
votes
1answer
24 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
25 views

Long numbers appearing when trying to retrieve element of 2D array - Game of Fifteen, pset3

I am working on the move function for pset3. I was having trouble matching the tile value to the board value, so I am now using print to make sure the correct value is coming up when I type board[i][j]...
0
votes
1answer
28 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
61 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
24 views

The won function in Pset3 fifteen works, but check50 gives me an error for it in the 3x3 table

So this is my code: bool won(void) { // check number int number = 1; for(int row = 0; row < d; row++) { for(int column = 0; column < d; column++) { if(number == (d * d) - 1) ...
0
votes
1answer
60 views

Pset3, Game of fifteen, move

I was trying to solve this Pset, and I believe there is something wrong in my move function, the if condition maybe?? I used debug50 and found out that the if loop takes part even when the move is ...
0
votes
1answer
42 views

won function does not seem to return true (even though it should)

So this has been a little frustrating. Even though the rest of the problem went well I cannot figure out where I went wrong. Here's the idea; set a counter called value that increments by every time ...
0
votes
1answer
32 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. ...
0
votes
1answer
59 views

game of fifteen help

yet again. i started working on the game of fifteen, i got it to work. But i had a lot of struggle with the won function. although it now works, i still don't know why it works. it was pretty much ...
0
votes
1answer
17 views

Move function keep adding blank tiles in some cases:

I have finished my move function and things. Still, the problem here is that sometimes the function works (either move and swap blank tiles correctly/ return false when appropriate) but sometimes it ...
0
votes
1answer
163 views

PSET 3: Game of fifteen. Everything in the board is equal to zero

CS50 community! I have a problem with my PSET 3. I've done only init() and draw() functions and can't understand what's wrong, so I can't go on. It prints blankspaces all over the board, so everything ...
0
votes
1answer
53 views

Game of fifteen move function duplicating “_”

My move function is duplicating the blank tiles instead of swapping. I even checked for the boundary conditions. It swaps immediate left and right ones, but the ones on top and beyond (illegal move) ...
0
votes
1answer
13 views

Why isn't my board populating?

When I paste my code into Python Tutor, I get the result I expect: view my code here. However, the code doesn't work in the CS50 IDE. An array of the correct dimensions is generated, but it is ...
0
votes
2answers
109 views

Pset3 Game of Fifteen Won Function

The won function for fifteen is driving me crazy! Here's my implementation. I've run it through debug50 and it appears to work as expected. However, check50 only passes on a 4x4 board, but not a 3x3. ...
0
votes
1answer
40 views

“Expected Expression” Error on Move Function

I am having a problem compiling fifteen.c. When I try to compile, I get an error in the move function saying: fifteen.c:225:27: error: expected expression coord_t = {i, j}; ...
0
votes
1answer
26 views

Game of Fifteen allows illegal moves and weird Tile swops Pset3

please help. My code seems to be allowing me to move tiles even when there is no open space. while the code correctly moves the underscore to the new space, in some cases, it does not move the tile to ...
0
votes
1answer
31 views

Check if the blank tile is next to the tile. Game of fifteen

guys! I am a beginner and not good enough at programming yet. On the game of fifteen I am trying to understand how this block of code works for a long time and still cant get the idea!:( bool ...
1
vote
1answer
40 views

Game of Fifteen Not Swapping Tiles and Allowing Illegal Movies

I have two issues with my code. First, while the code correctly moves the underscore to the new space, it does not move the tile to the space where the underscore once was. So I end up with a bunch of ...