Questions tagged [game-of-fifteen]

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

34 questions with no upvoted or accepted answers
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; ...
1
vote
0answers
113 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 ...
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
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
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
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
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
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
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
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
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
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. ...
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
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
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
0answers
91 views

pset3 move function

I have been banging my head against a wall for the last few days trying to figure out the move function. January 1st is fast approaching and I want to finish this pset and submit it before they ...
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
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
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
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
0answers
30 views

MOVE FUNCTION WORKS WHEN MOVING ALONG I BUT NOT J

I have been working on this one for a bit. I think I am close to having it work correctly. I have run into an issue where I can move tiles along the i but not the j. See below Move Function: bool ...
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
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
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
0answers
197 views

pset3 game of fifteen check50 error 10

I think my code works fine in the terminal but this is what I get in check50: :) fifteen.c exists :) fifteen.c compiles :) init initializes 3x3 board correctly :) init initializes 4x4 board ...
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
0answers
34 views

Only the blankspace is moving in my move function in the game of fifteen

Can someone please help looking into my code for move and draw? When executed, only the blankspace goes to the right position. The tile sometimes jumps to the next line and the board gets expanded. ...
0
votes
0answers
122 views

Move function not working in Game of Fifteen

I cant seem to find the bug why my move function is not working for me, any help would be much appreciated bool won(void) { int counter = 0; // loop for rows to start from one position left ...
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
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
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
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
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 ...
-1
votes
1answer
258 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) -...