Posted: Fri Mar 13, 2009 5:37 pm Post subject: RE:8 Puzzle Game
You need the puzzle.txt in order for the game to work. Plus I forgot to mention that it only works on windows . If people want to see another version, please let me know....it looks like that people aren't interested
Insectoid
Posted: Fri Mar 13, 2009 5:41 pm Post subject: RE:8 Puzzle Game
Mac version. Send me the source, I can compile it myself.
EDIT: woops, that is the source. Why won't it work on mac/linux?
A.J
Posted: Fri Mar 13, 2009 5:51 pm Post subject: RE:8 Puzzle Game
Try it and tell me if it does...Saad was telling it doesn't
A.J
Posted: Sat Mar 14, 2009 12:45 pm Post subject: RE:8 Puzzle Game
It is the "#include<conio.h>" that causes problem in mac/linux. I use that for keyboard input.
Insectoid
Posted: Sun Mar 15, 2009 9:45 am Post subject: RE:8 Puzzle Game
would it be possible to change that? Is there a different IO class that's multi platform?
EDIT: btw, command line compilers don't like your file names
saltpro15
Posted: Sat Mar 21, 2009 6:57 pm Post subject: RE:8 Puzzle Game
very cool I love how it can solve it for you and show you the necessary number of steps, very impressive A.J.
A.J
Posted: Sat Mar 21, 2009 7:10 pm Post subject: RE:8 Puzzle Game
Thanks saltpro15. It isn't too hard to code this. It actually took me about 20 - 30 minutes. The solving takes the most time (using BFS to work outwards from your state to the goal state).
Sponsor Sponsor
hkbnp
Posted: Sat Jul 11, 2009 6:17 am Post subject: RE:8 Puzzle Game
In Game(UC).cpp line 106, why the integer is 47?
can you talk about how to find out the integer?
A.J
Posted: Sat Jul 11, 2009 4:11 pm Post subject: RE:8 Puzzle Game
well, the ASCII value of '0' is 48. I use to convert between char and int.
wtd
Posted: Sat Jul 11, 2009 6:58 pm Post subject: RE:8 Puzzle Game
Instantly loses massive points for the use of global variables.
Also, learn to use header files for declarations of functions, and makefiles for compiling your programs.
hkbnp
Posted: Sat Jul 11, 2009 9:30 pm Post subject: RE:8 Puzzle Game
OK
i am trying to modify your program to 15 puzzle.i get error when solve the puzzle
void findGoalState()
{
int sum = 0;
for (int i = 0; i < 15; i++)
{
if (initialState[i] != '0')
{
for (int j = i + 1; j < 16; j++)
{
if ((initialState[j] != '0') && (initialState[i] > initialState[j]))
sum++;
}
}
}
if (backTrackState == currentState)
{
parentState[--index] = backTrackState;
break;
}
--index;
}
output(parentState);
}
A.J
Posted: Sun Jul 12, 2009 12:15 am Post subject: RE:8 Puzzle Game
what error do you get? (sry, don't hav compiler/IDE on me right now...)
we can continue this convo by pm'ing each other, k?
sry for not being able to help you sooner....
andrew.
Posted: Sun Jul 12, 2009 11:08 am Post subject: RE:8 Puzzle Game
I don't do much with C++ so I don't know about the IO modules, but I did some research about conio.h and it turns out that conio was used in the MS-DOS days and is no longer a standard library in C. The websites I've been reading recommend to use stdio.h instead. Like I said before, I don't do much with C++, so don't get mad at me if I'm totally wrong with this information.
saltpro15
Posted: Sun Jul 12, 2009 11:31 am Post subject: RE:8 Puzzle Game
even better, use #include <cstdio>
stdio.h is for C
cstdio is for C++