PDA

View Full Version : My First game (tic tac toe)


Blue Phoenix
06-03-2005, 11:35 AM
This is my first game, writen in Pascal.

I welcome tips and coments.

-------------
aside: my main compiler (free pascal) started giving |Fatal: Unexpected End of File| so I had to compile with Turbo Pascal 5.5

Kristian Joensen
06-03-2005, 02:44 PM
You couldn't choose a better language than Pascal. http://forums.3drealms.com/ubbthreads/images/graemlins/smile.gif http://forums.3drealms.com/ubbthreads/images/graemlins/cool.gif

Blue Phoenix
06-03-2005, 03:04 PM
And what pray tell is wrong with Pascal?

Shlubalubs
06-03-2005, 04:15 PM
He said you couldn't choose a better language than pascal, i dont think he was implying a negative comment about it. and your game has turned out good [for a game of noughts and crosses]

Eddy Willson
06-03-2005, 04:30 PM
Good game! http://forums.3drealms.com/ubbthreads/images/icons/thumbsup.gif

Do you plan to add anymore features?

Kristian Joensen
06-04-2005, 10:59 AM
Retro gamer said:
He said you couldn't choose a better language than pascal, i dont think he was implying a negative comment about it. and your game has turned out good [for a game of noughts and crosses]



That is the correct interpretation of my post.

Blue Phoenix
06-04-2005, 03:31 PM
Sorry, I instinctively interpreted it negatively because last time some bozos tried to convince me C or BASIC where better.


Eddy Willson said:
Good game! http://forums.3drealms.com/ubbthreads/images/icons/thumbsup.gif

Do you plan to add anymore features?



I'm going to tinker with the CRT unit which currently used only to clear the screen. Other things I may add, configeration file and rudimentary AI(will probably be random at first).

DudeMiester
06-06-2005, 12:58 AM
Make a perfect AI (not that hard really) and add a random error factor. Thats should do fine, and you can scale difficulty by scaling the error factor. You might want to add tallied repeating matches too (best of 5, best of 9, best of 2n+1, etc...)

Isamaru
06-13-2006, 02:11 PM
I signed up to look at your program hehe...

I built my own in Delphi4 and its a graphical program.

I was wondering if anyone could offer any advice on how to go about implementing a Human vs Computer procedure. I know the computer has to check a few things so it's not making random moves, but is there a certain way to do this?

Thank you for your help, I've attached a ZIP of the program if you want to take a look...

Tolle
06-13-2006, 05:55 PM
Console games like this bring back the "good old days" feeling :D

I had a lot of fun with SWAG (http://www.gdsoft.com/swag/downloads.html) ten years ago, when i learned PASCAL
There is some good stuff in there :)

Samji
07-01-2006, 09:32 AM
You couldn't choose a better language than Pascal. http://forums.3drealms.com/ubbthreads/images/graemlins/smile.gif http://forums.3drealms.com/ubbthreads/images/graemlins/cool.gif

@Blue Phoenix:

Observe the missing "?".


You couldn't choose a better language than Pascal. :)


is not the same as:


You couldn't choose a better language than Pascal? :(

8IronBob
07-02-2006, 11:19 AM
Yeah, I sorta wonder if Delphi has any backwards compatibility to traditional Pascal at all...

Drewcifer
07-20-2006, 09:57 PM
I suggest a brute force AI that runs through every possible scenario for each of its possible moves and selects the move having the most winning scenarios. This is the system Deep Blue used to beat whats his face. Of course, since the tic-tac-toe board is only 3x3, you won't need a super computer like Deep Blue.

Xerxes
07-20-2006, 11:12 PM
This is the system Deep Blue used to beat whats his face.
There's always a more effecient way though, so look for patterns unless it's fast enough. There are up to 362880 combinations according to math(so don't bother optimizing, I guess).

And if you use recursive functions, there's always a way to make each function no longer recursive but serve the same functionality.

Not sure what method to use but it's possible and will make the function more complicated.

Otto von Keisinger
07-20-2006, 11:57 PM
There's always a more effecient way though, so look for patterns unless it's fast enough. There are up to 362880 combinations according to math(so don't bother optimizing, I guess).
Actually, a bit of optimization, such as using a heuristic to avoid repeating the same calculations on further games (i.e., eliminating the particularly dumb moves), could significantly reduce that time. Of course, I haven't exactly thought it through, but perhaps using a few programmer defined rules to eliminate calculating the moves that will lead the computer to always lose in two turns or less could significantly speed up a brute force approach.

And if you use recursive functions, there's always a way to make each function no longer recursive but serve the same functionality.
O rly? Show me a non-recursive version of the Mandelbrot set, i.e., where you don't iterate Z=(Z^2)+C.

Xerxes
07-22-2006, 04:11 PM
do stuff
I can't quite figure out how to do a normal old set but pretend this works:

//Returns weather or not c1,c2 is in the whateveritwas set.
//Or is supposed to... It's borken and I don't really know why. (z1^2+z2^2)^0.5 is supposed to be 0.5ish in one instance and it's 0.7 so I get a white box when I run it. I'd blame it on float accuracy but I get a white box so it's probably my fault.
//Z1,z2 - set to 0 when calling
//C1,c2 - the number you're checking
//i - set to 0
//imax - So you don't get stuck in an infinate loop/stack overflow if the number works.
//So this would be a lot easier to call if I had remembered that you could set defaults for function parameters.
bool mc(float z1, float z2, float c1, float c2, int i) {
if (i>imax) { return 1; }
if (pow((z1*z1)+(z2*z2), 0.5) > 2) return 0;
return mc((z1*z1)+c1, (z2*z2)+c2, c1, c2, i+1);
}

You would change it to:

bool mc(float c1, float c2) {
bool res=1;
float z1, z2;
for (int i=0;i<imax) {
if (pow((z1*z1)+(z2*z2), 0.5) > 2) { res=0; break; }
z1=(z1*z1)+c1
z2=(z2*z2)+c2
}
return res;
}

Or whatever it's supposed to be.
You still have the accuracy problem but now it's not recursive.

Otto von Keisinger
07-24-2006, 06:27 PM
My point was that the Mandelbrot set falls into the category of programs that have to be iterated, as far as anyone knows. Turing came up with a proof that it is impossible to determine whether a recursive program terminates, e.g., the Mandelbrot set (there's a reason why it's called an escape time fractal). Basically, it involves a program ("checker") to test whether or not a(ny) program terminates. This checker is defined as running non-recursively.

It can be shown that this progam cannot exist. Suppose you were to run this hypothetical checker on itself. Since the checker requires code to test, there are an infinite number of possibilities. In fact, it is impossible to test the checker without having code to run on, in other words, the checker would have to be run to be tested. Therefore, it would have to break it's own rules to check itself, and it must not exist.

Oh, and you should know that Z and C are complex numbers, not floats. C is really Z0; blame the mathemeticians for not using a clear and consistent language.