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
99 views

game of fifteen won function (still!!) not working

I have been working on my won function for days now, and have read all the relevant posts on this site but still cant work out where I'm going wrong. The code does not return true when passed the 3x3....
0
votes
1answer
29 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
53 views

what does the fflush(file) do exactly?

I am trying to understand how fflush(file) combination works and why we need it here. Still I can`t figure it out. Can anyone help, please?
0
votes
1answer
51 views

won() function is not working

so I have this code for my won() and move() functions for the game of fifteen. I keep getting Illegal move error when I try to test my code with ./fifteen 3 < ~cs50/pset3/3x3.txt And this is my ...
0
votes
1answer
95 views

Pset3 (Game of Fifteen): The tiles won't swap… (“Illegal move”)

I have an issue with my code in Game of Fifteen. I get "illegal move" when I try to swap the tiles, even if it's a "legal" tile. I tried everything but I really don't understand what's wrong. Does ...
1
vote
1answer
27 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(...
1
vote
1answer
305 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 ...
0
votes
1answer
60 views

Game of fifteen - Move not doing what it's supposed to. Very confused

This is my move function for the Game of Fifteen. My board initialised okay but check50 is throwing errors at Move. For example:- :( 3x3 board, move blank up twice \ expected "0" character 5 of ...
0
votes
1answer
18 views

I switched my Blank space value to be 9 instead of 0, is this okay?

I am just finishing up the game of fifteen problem and went to use check50 to make sure everything was okay. I got this error: :( init initializes 3x3 board correctly \ expected "0" character 5 of ...
0
votes
1answer
50 views

Game of Fifteen - Move Function - getting wrong coordinates?

I have been working on the game of fifteen problem and seem to be having an issue. I keep getting an "Illegal Move" when it is a legal move. I think I have found part of the issue and I would just ...
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
50 views

Can't seem to figure out what's wrong with my code pset3 game of fifteen

Any and all help appreciated. Please and thank you. :) Here's my code: https://gist.github.com/noilddude/48e7d0f30ee5bb80d7e0f5d2490899b2 Here's what happens when I run check50:
0
votes
1answer
62 views

won returns illegal move when board reaches winning configuration

This is the code for the won() function. bool won(void) { int counter=1; for(int i=0;i<d;i++) { for(int j=0;j<d;j++) { if (board[d-1][d-1]!=0 || (board[...
0
votes
1answer
43 views

Debugging code for won function in game of fifteen

My code for won seems have correct logic but is not working.I could only check for 9 tile game as I only solved this so far but gametes not break out of loop and asks again tilt move after the winning ...
0
votes
1answer
24 views

What is the difference between draw function and given program lines for logging current state of board

Game of fifteen is asking us to write code for draw function. It is then followed by following lines of program to log current state of board My question is what is then the utility of the draw ...
0
votes
1answer
41 views

What is causing this compiler error in my logical operators?

I have a question about logical operators. I've written some code for Pset3, Game-of-Fifteen, as part of the "MOVE" function. This code aims to determine whether "tile" is in a "legal" position to ...
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
2answers
561 views

Pset3 - Game of Fifteen - init function

I am trying to complete the first step of game of fifteen - writing the INIT function. I've partially written a function that I think should work. The thing that is bothering me is this: I want to run ...
0
votes
1answer
60 views

Why isn't this move function from Game of Fifteen working?

bool move(int tile) { for(int row=0;row<d;row++) { for(col=0;col<d;col++) { if(board[row][col]==tile) { if(board[row+1][col]==0 || board[row-1][col]==0 ||...
0
votes
2answers
136 views

pset3: Help with Fifteen Move function

I need help with my move function. I can't figure out how to store the blank tile position only once without searching it together with the TILE input. Also, my move based on this code is always ...
0
votes
3answers
133 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
53 views

CS50 FIFTEEN my “move” function doesn't work

My name is Samuel and I'm 14 years old. I have been working on problem set 3 but have a problem with the "move" function. When an illegal tile has been inserted, it reply's with "illegal move" while ...
0
votes
1answer
99 views

fifteen pset 3 check50 error

[Update 1] Following feedback from DinoCoderSaurus, I have made changes to the code but the following issue still remains :( 3x3.txt wins the 3x3 board \ expected prompt for input, not exit code ...
1
vote
1answer
78 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 ...
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
77 views

check50 problems with fifteen from pset3

When I submit my program to check50 the first 4 lines of log.txt are missing in some of the checks. But when I compile the program with the same command locally or on CS50 IDE log.txt is correct. ...
1
vote
2answers
77 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 ...
0
votes
1answer
77 views

Problem Set 3 Fifteen - Draw function drawing more than it should

I've been working on pset3 game of fifteen in cs50 and when working on the draw function, the first output is exactly how it should be. However, if I restart the game by entering zero, then compiling ...
0
votes
1answer
169 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
71 views

Am I on the right track for won?

Can someone please tell me if my "won" logic will work? Will loop through each tile making sure first tile is 1, second tile is 2, etc. If a tile is not the expected number, return false(not sure if ...
1
vote
1answer
64 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 ...
0
votes
1answer
39 views

My program returns false even when I input a correct value for tile

void init(void) { int gridsize = d * d; for (int i = 0; i < d; i++) { for (int j = 0; j < d; j++) { board[i][j] = gridsize - 1; gridsize--; ...
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 '...
1
vote
2answers
182 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 ...
2
votes
1answer
33 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 -...
0
votes
1answer
150 views

Debugging move function in game of fifteen

I've been working on the move function for an inordinate amount of time now and I keep getting stuck on one issue. I can move the blank tile to the left (to get it out of the corner space), but cannot ...
1
vote
2answers
270 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 ...
0
votes
1answer
386 views

CS50 pset3 game fifteen won funcition

0 down vote favorite I am doing CS50 course now. I am trying to finish program fifteen. I have no idea what is wrong with won part of code. I guess the problem is with that part of code: if (...
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
103 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
32 views

guys i have an error in game of fifteen [duplicate]

look at my code in the pastebin link i don't understand the errors that are coming: http://pastebin.com/tuE5s3Em the error on compilation was: ~/workspace/pset3/fifteen $ make fifteen clang -ggdb3 -...
1
vote
1answer
85 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....
0
votes
1answer
120 views

PSET3 move() keeps showing “illegal move”

I am trying to make the moves happen. So far, the board shows correctly, with the 2 and 1 swapped if odd "d" is provided. But when I type any number at "Title to move:" it just keeps saying "Illegal ...
0
votes
1answer
114 views

Pset3 Fifteen won function reorders correctly but finished with illegal move, what's wrong?

I'm completely stuck. I don't understand what I'm doing wrong! My won functions correctly checks the game and allows for reordering of the entire board when checking with 3x3.txt but when it gets to ...
0
votes
1answer
403 views

Pset3/fifteen: move

I think some of the move code I've written is working correctly in that once the "Tile to move:" message appears and I enter a logical tile to move, I do not see the "illegal move" message, but when I ...
0
votes
1answer
100 views

pset 3 fifteen move() function; same code but works for left move and up move, not right and down

Here is my code /** * fifteen.c * * Computer Science 50 * Problem Set 3 * * Implements Game of Fifteen (generalized to d x d). * * Usage: fifteen d * * whereby the board's dimensions ...
0
votes
1answer
114 views

Pset3 fifteen - move: Tiles wont switch, “illegal move” error even when valid

I have been trying to get the tiles of the move function to switch if any adjacent cells are blank. The initiation and draw functions work fine, I just need to get the move function to make the actual ...
0
votes
2answers
170 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; ...
0
votes
1answer
64 views

Pset3, move function doesn't compile

I have a problem with compiling a fifteen.c. I've made init and draw functions with good result, they compile and work as they should, but when I moved forward I have some kind of bug with move ...
1
vote
2answers
51 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; ...