Questions tagged [game-of-fifteen]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
103 views

control may reach end of non-void function… but not really

I have an error message from the compiler that many others have reported, but I know why I got it and how to fix it. I'm posting this question because I think the error message is wrong and I'm hoping ...
0
votes
1answer
123 views

Game of Fifteen Move Function Duplicates Tile

In my Game of Fifteen code, the move function for the most part works, but once in a while, a tile will duplicate, looking a bit like this 1 1 2 4 5 6 7 8 _ As you can see, the number 3 ...
1
vote
1answer
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 ...
0
votes
2answers
150 views

Pset3 Fifteen: Can't use declared variable in the while loop

I am in move function of game fifteen pset3. I want to use a variable blank_i to show the position of blank. I have declared it globally (outside the while loop). But the compiler tell me that this ...
0
votes
1answer
313 views

Pset3 - Expected the file to be of length 18, not 21

Can someone tell me what exactly going on with my code and what does this error mean ? And what does this mean too -> "can't check until a frown turns upside down" ? /** * fifteen.c * * ...
0
votes
1answer
322 views

Pset3: draw() is printing out incorrectly

I've tested my init() and draw() together in a separate file, and it works exactly as it should. However, when I try implementing these functions within the fifteen distribution code, draw() prints ...
0
votes
1answer
178 views

Pset3: strange problem while testing init() function

I am trying to test the basic functioning of init(), but for some reason I am finding that for certain elements in the array, I am either missing a value or a value is doubled. Please help me ...
0
votes
1answer
434 views

pset3 - game of fifteen - expected file to be of length 18, not 0

I checked it with check50 and its throwing error : check50 2015.fall.pset3.fifteen fifteen.c :) fifteen.c exists :) fifteen.c compiles :( init initializes 3x3 board correctly \ expected file to be ...
1
vote
1answer
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 ...
0
votes
1answer
223 views

pset3: Why can't my init function print anything?

First of all I have no idea where to start but to get started anyway I did this and I have couple of questions -> 1- Why my printf is not working and what is the reason? 2- Except printf thing, am I ...
0
votes
1answer
216 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 ...
0
votes
1answer
1k views

Why is my pset3 fifteen won function not working?

It's still hard for me to see what I am doing wrong.. I am initializing a counter to 1. Then inside 2 for loops (to iterate over the board), I place the next code: if (board[i][j] == ...
1
vote
1answer
654 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 ...
1
vote
1answer
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 ...
0
votes
2answers
210 views

Pset3 2016 - Game of Fifteen: How to retrieve the index of an element in the 2D board array?

In Game of Fifteen, I am able to store the positional indeces of the blank tile at init; I know the blank tile is the last one, therefore the position is board[y-1][x-1]. What I am struggling with is ...
0
votes
1answer
231 views

Game of Fifteen swapping problem

My game works correctly except when I swap the values along the bottom row-both values turn into a blank space when swapped. Here is the move code: bool move(int tile) { for(int i = 0; i < d; ...
1
vote
0answers
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, ...
0
votes
1answer
1k views

pset 3 - game of fifteen - move tile

I'm currently working on pset3 game of fifteen, and my move function is not working. Below is my code for move(). bool move(int tile) { for (int i = 0; i < d; i++) { for (int j = 0; j < d; ...
0
votes
1answer
319 views

Game of fifteen move function won't swap tiles

I tried to change the code but it still won't swap tiles and blank_tile this is my code bool move(int tile) { int blanktile_X, blanktile_Y; for(int i = 0; i < d; i++) { for(int j = 0; j < ...
0
votes
0answers
96 views

Fifteen game move() not working and i dont know why

bool move(int tile) { // printf("number being entered &d", tile); nothing been taking in.. // get position of tile for (int x = 0; x < d; x++) { for (int y = 0; y < ...
0
votes
1answer
98 views

When swapping tiles, the value is set to zero

Why does my code to swap tiles give the value zero to board[d-1][d-3] and board[d-1][d-2]? printf("give me\n"); int d = GetInt(); int board[d][d]; int k = d*d-1; for(int i = 0; i < d; i++) { ...
0
votes
0answers
56 views

Can I remove the staff's comments from fifteen before submitting?

I've implemented init, draw, move, and won for Game of Fifteen. What part of the notes at the beginning of the file can I take out without messing up my code?
0
votes
2answers
197 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 ...
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 ...
1
vote
1answer
230 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 ...
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
461 views

How to compile Game of Fifteen framework?

I'm off to a very poor start on Game of Fifteen. The first task mentioned in "The Game Begins" is: "Go ahead and compile the framework. (Can you figure out how?)" I haven't been able to, and would ...
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
325 views

How and where to write code to check around tile? Pset3, Game of Fifteen

Been killing my head for too long with this. I get that we check around the tile when we find it in our loop, but then what? I understand completely, conceptually... yes, check around the tile for ...
1
vote
1answer
474 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 ...
0
votes
1answer
1k views

pset3 fifteen won function isn't working?

I've been trying to write the won function for days, but it has never worked correctly. I can't find any flaws in my logic, so can somone help me figure out what I'm doing wrong? ebool won(void) { ...
3
votes
2answers
29k 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
278 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
64 views

Tile no.1 won't move to position (0,0)

So my code seems to be working just fine up to the moment when I try to move tile == 1 to board position (0,0) either from the left or from the bottom. bool move(int tile) { if (board left == ...
-1
votes
1answer
259 views

In fifteen.c how do I print the current state of the board in draw()?

I don't understand how I can print the current state of the board in draw(). This is my code: for (int i = 0; i < d; i++) { for (int j = 0; j < d; j++) { board[i][j] = (d * d) -...
1
vote
1answer
444 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(); ...
1
vote
1answer
433 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 ...
0
votes
2answers
532 views

pset3 fifteen move creates double numbers

So my move function finally compiles, but when I run the program and chose a legal tile (i.e. one by the blank) the blank turns into the tile I picked. So from this: 8 7 6 5 4 3 2 1 ...
0
votes
2answers
246 views

pset3 fifteen move doesn't compile

First of all I know there are two questions very similar to this one but the answer I'm looking for is not there. I'm working on my "move" function for fifteen in pset 3. I keep getting the "control ...
0
votes
1answer
106 views

What is if(!move(tile)) and can I change it?

I don't understand the if(!move(tile)) condition in pset3. Can anyone please explain it to me? Can I change this code?
0
votes
1answer
467 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!
0
votes
2answers
501 views

How to pass grid values to draw in pset3

I've just finished coding init and have started draw but I'm not sure how to pass on my grid values to the draw functions. Especially as the values may change as the user plays the game. I've tried to ...
2
votes
1answer
790 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 ...
2
votes
2answers
264 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 ...
1
vote
1answer
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++...
1
vote
2answers
99 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 ...
1
vote
2answers
29k 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: ...
0
votes
1answer
108 views

Dereferencing 2d pointer to print board

I've used pointers to help create my game of fifteen grid, and now I want to print out the board using 'draw'. The function works to the point that the board prints, but instead of array elements I ...
0
votes
3answers
681 views

Error in my logic? Pset3 Won

Could someone explain me why my superb idea isn't working? Okay, perhaps it isn't that superb but it was my original own idea. In pset3 fifteen game when seeing if the game is won, I first created a ...
1
vote
2answers
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?