Skip to main content

Questions tagged [game-of-fifteen]

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

Filter by
Sorted by
Tagged with
3 votes
2 answers
37k 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 ...
nivedita shrivastava's user avatar
3 votes
3 answers
416 views

Blank tile without using a variable

Regarding the blank tile in Game of Fifteen, can I avoid using a variable for the blank? In other words, can I just print an underscore when I reach zero in my array?
user261819's user avatar
2 votes
1 answer
829 views

Where can I find 3x3.txt?

So I've gotten to the end of my coding for fifteen and sure, I could try and solve it myself (I'm lazy), OR I could load up the 3x3.txt file. However, I'm having trouble finding the location of this ...
Andrew Gray's user avatar
2 votes
2 answers
41k views

How do I fix a "use of undeclared identifier" compilation error?

In the following code snippet: for (int column = 0; column < d - 1; column++); { board[&row][&column] == counter; counter++; make returns the following error: fifteen.c:140:19: ...
xkalibur's user avatar
2 votes
2 answers
267 views

Why Aren't My Last Two Tiles Swapping?

I'm trying to come up with something to change the tile numbers in the last two array slots, containing numbers 1 and 2 when I have an odd number of tiles. I thought this would work, but when I print ...
Andrew Gray's user avatar
2 votes
1 answer
34 views

Fifteen: Error in a function I haven't touched yet

I am working on the last part of pset3 (game of fifteen). After trying out my code for the init and draw functions, I tried to "make" it and receive this message in the terminal (CS50 IDE). clang -...
Ch. Katsidonis's user avatar
2 votes
1 answer
751 views

Pset3 Fifteen Check50 not Working

My code works when using the 3*3.txt as well as when I play it, but it is not accepted by check50. Here are my check50 errors: :) fifteen.c exists :) fifteen.c compiles :( init initializes 3x3 board ...
mmoore's user avatar
  • 57
2 votes
1 answer
149 views

How do I get to work gdb to check my Won function in game of fifteen

there is a staff implementation of predefined set of moves for a 3 x 3 board which can be executed by ./fifteen 3 < ~cs50/pset3/3x3.txt I was working on my Won function, can some one tell me how ...
Furrukh Jamal's user avatar
1 vote
2 answers
1k views

Pset3 Fifteen Move function

I dont even know how to begin the move function, can somebody give me some ideas please? Probably by searching the tiles position, but how can i do that?
Joao Turolla's user avatar
1 vote
2 answers
278 views

PSET3 Game of Fifteen move() Problem

I'm sorry for making another post of this, but I don't want to look other classmates' code while I'm still trying to do this myself. I'm having trouble with move() in fifteen.c. I'm not sure how to ...
Osman Zakir's user avatar
1 vote
1 answer
4k views

move function, pset3

I'm having trouble with my move funtion in the game of fifteen. For some reason the chosen tile and the adjecent zero won't swop places. I've been working on this function for too long and reaching ...
SurTJ's user avatar
  • 15
1 vote
1 answer
310 views

Game of Fifteen pset3 - won() function works, but why?

I've managed to get a thumbs up from check50 in the Game of Fifteen, but I have no idea why. It's really eating at me and I refuse to go forward until I understand it. Here's my less than eloquent ...
rane's user avatar
  • 15
1 vote
3 answers
154 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 ...
Samuel Hanssen's user avatar
1 vote
1 answer
135 views

Am I going about Init() correctly?

I'm wondering if I'm going about Init() correctly. It took me quite some time to understand what I was supposed to do. I realized drawing out the actual board on paper helped a lot. Anyways, here is ...
Pixeluh's user avatar
  • 25
1 vote
1 answer
635 views

pset3 fifteen's draw function problem

I'm trying to make draw function but i can't seem to have values which i have done in init() function. When i compile and run the program i have zeros all over the display. Can anyone address me ...
Habib ur Rehman's user avatar
1 vote
1 answer
232 views

Global variables to store the position of the blank space?

I tried to implement a leftward movement in game of 15. I encountered a problem. The program can only call move function once and it doesn't work after that. I use 0 to as the representation for the ...
Lucas's user avatar
  • 171
1 vote
1 answer
481 views

Swap 2 and 1 after looping, pset3, Game of Fifteen

I don't know why my positions at 2 and 1 in my odd numbered tiles are not swapping. Here is a mix of pseudo code plus my swap conditional. See anything that is wrong? Thanks. // board, whereby ...
Azurespot's user avatar
  • 203
1 vote
1 answer
43 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. :) ...
faedx's user avatar
  • 25
1 vote
1 answer
46 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 ...
Alex Durante's user avatar
1 vote
1 answer
79 views

CS50 PSET3 FIFTEEN compiles but fails to work properly

Dear StackExchange users, My name is Samuel and I'm 14 years old. I am completing Problem Set 3 but am stuck on fifteen.c. My program compiles and runs. When I run the program, I get the normal ...
Samuel Hanssen's user avatar
1 vote
2 answers
83 views

Check50 Error (pset3, fifteen)

In my own testing my fifteen game compiles without errors and works perfectly. However, when I checked it with check50 it said that it couldn't initialize the boards correctly, and I got this: Then I ...
Jason Chadwick's user avatar
1 vote
2 answers
185 views

PSET3 : fifteen: how to identify board edges in move function?

Hi I am working on pset3 : fifteen and trying to implement move function. I'm not quite sure how to identify board edges and deal with this. My swap is also not working as the tile I want to move ...
i'i'i'i'i'i'i'i'i'i's user avatar
1 vote
1 answer
674 views

expected an exit code of 0, not a prompt for input WON

I'm still stuggling with the game of fifteen, and I could make it works. However, when I run check50 it displays :( 3x3.txt wins the 3x3 board \ expected an exit code of 0, not a prompt for input :...
Maggie's user avatar
  • 14
1 vote
1 answer
209 views

pset3 - Why numbers are disappearing when I'm playing game of fifteen?

I'm fed up of checking the fault in my code and when I'm playing the game it disappears some numbers like in first step when I try to swap the blank space with 1 I get two blank spaces and 1 gets ...
Priyanshu Kumawat's user avatar
1 vote
1 answer
1k views

fifteen.c : printf() not printing anything to the screen

To check the execution sequence of the code, I have added printf statement just below the main(): int main(int argc, string argv[]) { // greet player printf("abc \n"); greet(); ...
chiragpatel39's user avatar
1 vote
1 answer
441 views

pset3 - 4x4.txt winning sequence not working - problem with move function?

When I play fifteen myself it works with any board size; the 3x3 winning seq also works, but the 4x4 one does not finish and stops while repetitively trying to move tile 2147483647.. GDB did not help ...
pat_krat's user avatar
  • 570
1 vote
1 answer
274 views

won() Doesn't Work Properly

My won() function works properly when the board dimensions are 3 x 3. However, it doesn't work properly when the board dimensions are 4 x 4. What could possibly be wrong? for (int i = 0; i < d; i++...
sousheel's user avatar
  • 149
1 vote
2 answers
101 views

The Case of the Disappearing Tiles

I just finished trying to implement my move function. It seems to work to a certain extent, except that some of the tiles keep turning into blanks. I have the following code for my swapping: for (int ...
dottified's user avatar
1 vote
2 answers
98 views

Do we have to implement game of fifteen in pset3 using graphics?

Does fifteen.c had to be implemented in graphics, by including graphics.h and creating the tiles as graphical objects?
user1445's user avatar
1 vote
1 answer
65 views

Pset3 Move GDB Problem

I am stuck on the move part of fifteen and trying to learn how to use GDB. My thought process for moving is to search for the "tile" and if the tile is adjacent to the "_" then switch. during GDB, i ...
coldeskimo03's user avatar
1 vote
1 answer
88 views

pset3 move() makes every tile swapped a blank tile

I rewrote almost the entire code and I finally was able to make the tiles swap. Problem is at every swap the blank tile gets duplicated and the tile swapped disappears, eventually rendering a Segfault....
Lele's user avatar
  • 67
1 vote
2 answers
53 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; ...
Ahmed Raza's user avatar
1 vote
1 answer
213 views

how does check50 test the "fifteen" code?

Can someone tell me how is check50 testing fifteen.c? My code is failing (see error below) the test, but if I try to do the steps that are failing, I see nothing wrong. 3x3 board, from start try ...
Alexis's user avatar
  • 25
1 vote
0 answers
115 views

Fifteen.c -> expected file to be of length X "cheap solution"?

I've been having some trouble with the fifteen game code. Even though it works as expected, when I do check50, I get a bunch of errors related to the expected size of the log file. After looking at ...
Alejandro Aristizábal's user avatar
1 vote
1 answer
659 views

pset3 fifteen not passing check50 but works

I am working on the game of fifteen on pset3. The code runs fine on my computer but fails check50. I have stepped through it in gdb and can not find what check50 is talking about. The two tests it is ...
arortell's user avatar
1 vote
0 answers
237 views

game of fifteen check50 error [closed]

The program seems to run fine but when I execute check50 I get this message: :) fifteen.c exists :) fifteen.c compiles :( init initializes 3x3 board correctly \ expected file to be of length 18, ...
Esteban's user avatar
  • 11
1 vote
4 answers
468 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 ...
Jason Keane's user avatar
1 vote
1 answer
31 views

PSET 3 can't get move to swap tile above blank

Keep getting illegal move on following code and can't figure out why it won't swap. I am selecting the tile above the blank in testing. /** * Prints the board in its current state. */ void draw(...
BoBbY's user avatar
  • 25
0 votes
2 answers
854 views

Pset3 won-function works only with 3x3 board. Where am I wrong?

Pset3 won-function successfully passed this test ./fifteen 3 < ~cs50/pset3/3x3.txt only for a 3 × 3 board. For a 4x4 board the program's output is: 1 2 3 4 5 6 7 _ 9 10 12 ...
Nina's user avatar
  • 5
0 votes
1 answer
55 views

Fifteen move not working in last row only

I am very new to this, so I am at a loss as to why my code isn't working. I am trying to make my move function work in the game of fifteen, and it works as long as I am not going to the left or right ...
Leanne's user avatar
  • 3
0 votes
2 answers
109 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[...
Daniel-G's user avatar
0 votes
1 answer
76 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-...
Ashley Moe's user avatar
0 votes
1 answer
203 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 ...
Svitlana Honcharuk's user avatar
0 votes
2 answers
173 views

Pset3/Fifteen/Init Function - Problem with 1 and 2 swap

void init(void) { int start_tile = (d * d) - 1; for (int i = 0; i < d; i++) { for (int j = 0; j < d; j++) { board[i][j] = start_tile; ...
Flesheaters's user avatar
0 votes
1 answer
217 views

Pset 3: Fifteen - Moving up and down but not left or right?

I am running into problems with fifteen. Specifically, the move function. I can make numbers move up and down, but somehow I've messed up the left and right and I'm not sure how. When I try, it sets ...
Fobok's user avatar
  • 82
0 votes
2 answers
198 views

All my moves entered are shown illegal, though code doesn't seem wrong... (PS3 - fifteen)

I have checked draw() and init() and they seem to be right. However, the problem lies with the move() portion of the code. After I run the code, every move entered is named Illegal.... I have no clue ...
Happytreat's user avatar
0 votes
1 answer
470 views

pset 3 "control may reach the end of a non-void function" [duplicate]

I know what this error means, but how do I fix it? I'm using a if... else... function, so I'm not sure how to improve upon that. Thanks!
Yao Li's user avatar
  • 33
0 votes
1 answer
516 views

How to Print the Blank Tile in the Game of Fifteen

In Game of fifteen we are asked to print a blank space at the end of the game, they fistly tell us to put the last number as any Int, then they ask us to print something that is not the int we chose, ...
Joao Turolla's user avatar
0 votes
1 answer
32 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]...
melbez's user avatar
  • 105
0 votes
2 answers
116 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. ...
Jason_V's user avatar
  • 182

1
2 3 4 5