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

CS50 Game of fifteen, Move Function, checking for legal move

I have tried many different variations of the check feature of the move function to try and find if it is a legal move. This is about my forth attempt and I still cant get it to find an illegal move. ...
0
votes
1answer
29 views

CS50 Fifteen - when I run my check I get an error saying the file is a few larger then it needed to be

When I run my program it works correctly but when I use the CS50 check I get an error saying that the length of my files are the amount of moves to be made more then it was supposed to be. For example,...
0
votes
1answer
37 views

Check50 initialising error pset3

When I run check50 on my code, I apparently initialised the board wrong. https://sandbox.cs50.net/checks/e8394a83a4b645199b6b74abbb525f89
0
votes
1answer
115 views

Pset3; won(). Wins 4x4, but not 3x3

bool won(void) { int counter = 1; // sets counter to 1 (as the [0][0] will start from 1 upwards to d*d-1.) for (int i = 0; i < d; i++) // goes over the board to make sure everything is at ...
0
votes
1answer
149 views

Pset 3 : Game of fifteen. Help understanding the error message

I am working on the game of fifteen on problem set 3. The code runs fine but fails check50. the error message is as follows: :) fifteen.c exists :) fifteen.c compiles :) init initializes 3x3 board ...
0
votes
1answer
216 views

Game of fifteen

I have completed Game of Fifteen which works fine using txt inputs check, but if fails to pass check50. Here is the code: https://github.com/bmind12/CS50/blob/master/pset3/fifteen/fifteen.c ~/...
0
votes
1answer
68 views

fifteen move issue

Can anyone see the issue here? It moves "5" from the start position ok, but when it comes to "1" it is just two blank tiles in adjacent squares ("1" disappears). Obviously there is some issue with the ...
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
17 views

Error in dependency - pset3 fifteen

...I really don't get this one. I don't. First, the sandbox. https://sandbox.cs50.net/checks/7928ff4d4d08499ab0e97441cb6dd2d5 Now the code: void init(void) { //partial credit to code goes to ...
0
votes
1answer
66 views

PSet 3 - Game of fifteen - draw tile gives weird output

I have not been able to draw the board properly. Whenever i run the code ~/workspace/pset3/fifteen/ $ ./fifteen 4 WELCOME TO GAME OF FIFTEEN 15 14 13 12 11 0 0 4196528 0 0 -186283616 32766 48 -...
0
votes
1answer
81 views

problem while playing game of fifteen

after the first move,rather than displaying a underscore(_) it is dislaying 0, and in the place of moved number it displaying a underscore and then move numbers with respect to zero.here is my code. /...
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, ...
1
vote
1answer
209 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 ...
0
votes
1answer
54 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 ...
0
votes
1answer
89 views

Pset3 draw function outputs zeroes or random numbers

When using 3, 4 or 5 as dimensions the function gives me the expected output but when I use 6 and above my output looks like this 1 32766 958277840 32766 5 6 6 0 0 0 958277824 32766 -...
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
1answer
43 views

GAME OF FIFTEEN DRAW FUNTION IN NOT SWAPPING

I am working on game of fifteen as my title states. Can someone help explain why my swapping of "2" and "1" is not printing. draw() is below : if(d % 2 == 0) { int temp; temp = board[d][d ...
0
votes
1answer
24 views

pset 3 - can't get to move anything

Every tile I try to move, it return "Illegal move", I was quite sure the code was right, but I can't find where is the mistake. :( Any tip you can give me is appreciated! bool move(int tile) { int ...
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
19 views

Why does the variables passed on as arguments don't maintain their modified values?

Currently I am on 'Game of Fifteen' part of pset3, and I am having problem with my implementation of the function move. The function move calls a function legalMove which in turn calls another ...
1
vote
1answer
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 ...
0
votes
1answer
83 views

pset3 - Game of Fifteen can move in basic directions, but not in combinations of moves

My Game of Fifteen seems to work when I try to move in the four basic cardinal directions, but when I use check50, the game seems to brake in unexpected places (such as after several moves). For ...
1
vote
1answer
670 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 :...
0
votes
2answers
642 views

Pset3 Fifteen: Draw and/or Init Function Problem

I cannot figure out why this code is not working. The output appears to be random. Any help is greatly appreciated. Thanks! My Init code: void init(void) { int MAX = (d*d)-1; int below = 0; ...
0
votes
1answer
156 views

Pset 3, Move, What am I doing wrong?

Please give me some suggestions, I think I'm reasonably close: bool move(int tile) { int temp; int didSwap; int blankRow; int blankCol; // search for blank tile for(int row =...
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
1answer
37 views

Pset3, Fifteen. Why isn't my code printing a new line after each [i] increment?

I'm working on my 'draw' function. I'm managing to print the array yet for some reason, it's printing it in one long line as opposed to a grid. Here is my code: void init(void) { // initilizes ...
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
1answer
93 views

problem in drawing the board of game of fifteen

I just started the game of fifteen ,so i thought of drawing the board in this way char space=' '; for(int i=15;i>=1;i--) { for(int j=i;j>=i-3;j--) { printf("%2d%c",j,space); ...
2
votes
1answer
146 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 ...
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
1answer
75 views

I am stuck on pset3. I am getting an error while implementing move() function in fifteen.c?

These are the checks that I have been prompted. https://sandbox.cs50.net/checks/40ebaa6203d64aef9d34d86f8537a589 And my code is here: https://gist.github.com/Anirudh257/...
0
votes
1answer
50 views

Move function not working

I'm having trouble with the move function in Game of Fifteen. Tried a lot of different ways, but couldn't get any to work. Code is at [deleted]. Not trying to keep user input within bounds of board ...
0
votes
1answer
617 views

pset3 Game of Fifteen check50

My code runs fine, but check50 gives this error: :) fifteen.c exists :) fifteen.c compiles :( init initializes 3x3 board correctly \ expected file to be of length 18, not 27 :( init ...
2
votes
1answer
746 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 ...
0
votes
1answer
491 views

Pset 3 Fifteen: “use of undeclared identifier 'new'”

I've been working on Fifteen, and I want to insert the values into an array (in init) but for some reason, it doesn't know what 'new' is. When I try #include <new>, it says it cannot find said ...
0
votes
1answer
278 views

PSET3 Fifteen Won Function not returning True

In the 'Won' function I tried to do two things: check if the array is in order and to cater to the blank space (underscore in my case) I used the counter method to check if each cell corresponds to ...
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 ...
0
votes
1answer
361 views

Can’t get pset3 fifteen fails 3x3 and 4x4 txt wins the board

My thanks in advance to anyone who can fix my logic. I’m a beginner in every sense. I’ve read every post tagged w/”won.” I can’t get gdb to debug “won" and have manually mapped out i and j values (...
0
votes
1answer
305 views

Pset3 game of 15 move function

For some reason whenever I try to swap 0 with board[0][0] I get an illegal move error. Besides that everything is fine. What gives? int column = 0; int row = 0; int box; int space; for (int i = 0; ...
0
votes
1answer
150 views

pset3 won code looks like it should work but doesnt…

So I finally got the code working when it looks like this: int k, l, m = 0; for (k = 0; k < d; k++) { for (l = 0; l < d; l++) { if (board[k][l] == m + 1 &...
0
votes
1answer
197 views

getting error from check 50 fifteen\ expected “8” character 1 line 1, not “0” exp. file to be of length 38, not 32

Having trouble with my code here, cant get the numbers to appear at all, much less in a 2d array, outputs 9 "_" chars separated by new line every time. I apologize for my lack of understanding of how ...
0
votes
1answer
158 views

move function doesn't move blank tile sideways [duplicate]

I've just implemented the move function and, when I was testing, I found that it didn't work when I swapped the blank tile with another number on its side, like this: (I tried swapping 1 with the ...
0
votes
1answer
271 views

fifteen initialize not working correctly

so the line of code below gives me the output of: 2|3|-4 -3|-2|-1 8|-7|95 Can anyone see what I ve done wrong? Thank you. void init(void) { for (int i = 0; i < d; i++) { for (int ...
0
votes
1answer
81 views

pset3 fifteen adjacent check not working [duplicate]

working on pset3 fifteen.c. I think that something is wrong with my adjacent checking in my move function. It says "Illegal move" even when I choose an adjacent tile. /** * If tile borders empty ...
0
votes
1answer
169 views

pset3 fifteen - how to check if tile is adjacent to 0/“_”?

I have tried to do this, but it has only resulted in a segmentation fault.
0
votes
1answer
187 views

PSET3 fifteen - part of move is not working and 1 and 2 switch

close to finishing pset3 fifteen.c. When I am playing with fifteen, everything is working except for when I attempt to switch "" with 8. There ends up being 2 ""s. I think that it might be something ...
0
votes
1answer
88 views

Board not being drawn correctly Game of Fifteen

void init(void) { int grid = (d * d) - 1; for (int i = 0; i < d; i++) { for (int j = 0; j < d; j++) { board[i][j] = grid; grid--; } ...
0
votes
2answers
588 views

pset3 fifteen.c Illegal move after almost solving it!

Question: What causes this error?! Terminal Output when running those 2 commands, Always stuck to almost solving them, then Illegal move ./fifteen 3 < ~cs50/pset3/3x3.txt ./fifteen 4 < ~cs50/...