News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

How to implement min-max algo in playbasic?

Started by ScottieB, February 12, 2015, 01:07:06 PM

Previous topic - Next topic

ScottieB

I did some research on min-max algo for games like tic-tac-toe ect...
I know it has to be a recursive in nature.

I'm just not sure on how to implement this?
I get the idea but not sure how to program it.

Any ideas or can someone show me some example program.  Even if it is tic-tac-toe.

Please &
Thanks.

kevin

  some links so people to get some background,

  http://www.flyingmachinestudios.com/programming/minimax/
  http://neverstopbuilding.com/minimax


ScottieB

I think I have it here.
Can someone please check if this data is accurate?
It's three tiers down so far.
It's not done but I want to see if this is sort of it.
Anyone who can also show me how to print this data to a file so I can verify it also please help!
Thanks
ScotttieB

kevin

 There's a number of log file styled functions on the source code board..  WriteToLog - Logging LIbrary

To read/write to a file look the HELP under FILES.. 


ScottieB

Here it is working!

I think I might need someone to adjust it a bit.

Right now it is using positive and negative numbers to either block opponent or take a win.
The number system is correct and it states that the lower the number in the depth tree means the smarter the game is played out.
I was only able to go 6 Tiers down so that's two moves ahead for both players.

Can someone help me to use the numbers better.  Right now it's using 1's to block me to win and 2 to take a win.  This is good however this is not using the depth values well enough.
Can someone help me straighten it out a bit.

Yes,  This algorithm can be used also in game like connect four and chess.

I just want to understand it better with a working model.
Thanks
ScotttieB

kevin

#5
 Seemed to work, but I don't have time to look closely at it. One thing that did strike  me is the size of those arrays, which are approximately 163 meg...




------------------------------------------------------------------------------------------------------------
[VARIABLE & ARRAY DATA]
------------------------------------------------------------------------------------------------------------
[
VARIABLES
[
Integers =328 Bytes
Floats =4 Bytes
Strings =148 Bytes
]

ARRAYS
[
Integer Arrays =167404464 Bytes
Float Arrays =0 Bytes
String Arrays =0 Bytes
Typed Arrays =0 Bytes
]

Program.Variable Memory Usage =480 Bytes
Program.Array Memory Usage =167404464 Bytes
]