PDA

View Full Version : novice needs help



emorej29
28-06-2008, 12:16 AM
i have to make a game like

5 4 8
9 6 1
2 3

to be able to move the tiles from spot to spot...i got down to making the tiles appear randomly but the moving is giving trouble

help meeeeee

in pascal

waran
28-06-2008, 12:36 AM
I'd like to help you but first I have to see some code of yours since
my magic crystal ball broke when I gave it away for cleaning.

If you store your "board" in an array then moving is as easy as
swapping two fields.

Edit:
Oops. You made me feel challenged by it and I wrote a similar game
this night. Feel free to gather inspiration. If you don't understand a part
just ask and I (or somebody else) will explain.

http://nopaste.info/3f9d840950.html

Note: Mixing the array this way makes the puzzle come out unsolvable
very likely. So think of something else :D

emorej29
28-06-2008, 01:02 PM
I'd like to help you but first I have to see some code of yours since
my magic crystal ball broke when I gave it away for cleaning.

If you store your "board" in an array then moving is as easy as
swapping two fields.

Edit:
Oops. You made me feel challenged by it and I wrote a similar game
this night. Feel free to gather inspiration. If you don't understand a part
just ask and I (or somebody else) will explain.

http://nopaste.info/3f9d840950.html

Note: Mixing the array this way makes the puzzle come out unsolvable
very likely. So think of something else :D


explaination is def needed, can u contact me via email, do u use messenger add me at romey1929@hotmail.com, whoever so desires to help me.thanksssssssss

ima give u what i have so far so



EDIT:

THIS IS WHAT I HAVE

http://nopaste.info/21e7695114.html

waran
28-06-2008, 03:30 PM
Why did you start another thread? You can edit your post, too.
As for me I refined my code a bit. It should be easier now:

http://nopaste.info/e527f05456.html

Back to your code:
You really have to ask more precisely where exactly your problem
lies / which code fragment doesn't work as you expect.

Much like the friendly admin in the other topic wrote: Its not like writing
"help" and you get a full working code including documentation .)
I merely wrote the game by myself because I felt bored.

And for gods sake indent your code. My eyes hurt from guessing what
belongs to what (this distracts me from finding your mistakes ;)).
Btw.: I guess nobody is going to EMail or IM you. A Forum is meant to
share wisdom; its not some market where you can buy your personal
debugger.

emorej29
28-06-2008, 05:21 PM
...ha!

wat is php?

waran
28-06-2008, 05:38 PM
Just forgot to change it before posting; the code is in pascal nonetheless.

emorej29
28-06-2008, 07:31 PM
whats the difference between the first and second one u did....addition or totally different thing to work betta?

waran
28-06-2008, 09:59 PM
The second one has some slight improvements. Mainly it uses more
modularity (complex problems broken down into small procedures) so its
easier for you to understand.
You can deduce from the function names what I do - also I commented
the "IsMoveValid"-Part better. It might look strange, but if you think
about it its actually easy.

Also it doesn't randomize the game-board at startup but uses a static
starting situation (since the "wild" randomization can produce unsolvable
puzzles, as I wrote before). I made this one by myself and its solveable
in 10 moves.

But actually you should see the differences?

emorej29
28-06-2008, 10:24 PM
i was going through it, making sense of it but I guess how we were taught makes it difficult to read. but when i do run it it does give the option to have the tiles moved or anything, everytime i runs it goes str8 to ...what i mentioned above.

i am not just trying to have u do my stuff for me, i have tried lots of stuff, but we werent taught what we shoul dhave been, the class was rushed, hence the reason why i resorted to seekig help online.

waran
28-06-2008, 10:40 PM
It seems like your problem is you are not familar with pascal.
In this case you should seek help here:

http://www.taoyue.com/tutorials/pascal/index.html

I can't get what you mean by

but when i do run it it does give the option to have the
tiles moved or anything, everytime i runs it goes str8 to ...what
i mentioned above.

Its gibberish. You can compile my code with Freepascal (delphi or
objfpc mode) or Delphi - maybe newer Turbo Pascal versions also -
and run it.
The program runs in console and you enter the number you want to
move and press enter.

emorej29
29-06-2008, 01:06 AM
It seems like your problem is you are not familar with pascal.
In this case you should seek help here:

http://www.taoyue.com/tutorials/pascal/index.html

I can't get what you mean by

but when i do run it it does give the option to have the
tiles moved or anything, everytime i runs it goes str8 to ...what
i mentioned above.

Its gibberish. You can compile my code with Freepascal (delphi or
objfpc mode) or Delphi - maybe newer Turbo Pascal versions also -
and run it.
The program runs in console and you enter the number you want to
move and press enter.


i meant when i run it it does NOT




hey i downloaded the free pascal thing and it is coming up with an error there

waran
29-06-2008, 08:44 PM
I actually ran tired of telling you stuff based on virtually nothing coming
from you. I reconnement reading this:

http://www.catb.org/~esr/faqs/smart-questions.html

User137
30-06-2008, 10:09 AM
I think it is just difficult getting answers to a program that is made for text based OS or console which hardly anyone programs anymore.


i have to make a game like

5 4 8
9 6 1
2 3

to be able to move the tiles from spot to spot...i got down to making the tiles appear randomly but the moving is giving trouble
Store 3x3 array and X,Y coordinates for the empty tile. Whenever you move from position to other, read the number, write it to old coordinates and clear the cell in new coordinates.

In console like UI you need to input direction to move, for example U,D,L,R for up,down,left,right or you can read actual arrow keys or w,s,a,d.