Chess AI

Blitz3D Forums/Blitz3D Beginners Area/Chess AI

Craig H. Nisbet(Posted 2004) [#1]
Anyone ever tried writing Chess AI in Blitz. I'm been doing a little research, what I found refers to a Minimax tree searching system, but I can't seem to find any coded example of it. Anyone know of this stuff, or tried to code it?


Ross C(Posted 2004) [#2]
I'm currently coding a chess AI system. I don't quite know where to start tho. A couple of ideas involve checking all of the human players moves (when it's the computers turn). Store this in an array, the squares in which the human player can move to. The array is a 8*8 representation of the board, and each 'square' will have a danger value, based on the above.

Eg. if a square can be landed on by several of the human players pieces, it will have a higher value in the array. If the square is safe, then the computer will choose between all the safe squares.

However you can expand upon this further, to make the computer harder to beat. When the computer has selected a square, you do a scan of all the possible moves the computer can make (using the safe squares figured out above). And see which one is the most threatening. Again, you can go further and scan all these moves to make sure there safe.

The problem is, all this takes time to do. You could at first be scanning 80 moves of the human player, to gather information about the danger squares. Then you need to assess each of your pieces against the grid.

Hope that sheds some light. It may not be the most common way to do it, but that's the way i'm going with it :) And good luck!


(tu) sinu(Posted 2004) [#3]
don't forget chess isn't just about the next move, but the next few moves, don't want the ai picking the safest square for the next turn but on the following 2 turns losing the match cos it was getting setup.


jfk EO-11110(Posted 2004) [#4]
you might try to port some existing chess source that was released to the public. will probaby save your day from headache.


eBusiness(Posted 2004) [#5]
There is a game called Arcade Chess, made with Blitz, no matter what you do, do it different. I took down the "hardest" AI in 6 moves. But the gfx was good (whatever)


(tu) sinu(Posted 2004) [#6]

There is a game called Arcade Chess, made with Blitz, no matter what you do, do it different. I took down the "hardest" AI in 6 moves. But the gfx was good (whatever)



stop being moddest, you were just that damn good :)


tonyg(Posted 2004) [#7]
Have you seen the Chess AI articles here...
http://www.gamedev.net/reference/list.asp?categoryid=18


Shambler(Posted 2004) [#8]
I've thought about making a chess game many times, I suppose we all have.

There are just 2 goals in chess,

1) Avoid your King being in checkmate
2) Get the oppositions King into checkmate

I thought about weighting each piece for its value e.g. a pawn worth is 1 and a queen is worth 10 but I see now that that is not important at all!

The important thing is to achieve goal 1 above, it doesn't matter what pieces you lose on the way as long as it achieves the goal.

I imagine you would make a recursive function:
For each piece
For each position that piece can move to
Does this get us closer to goal 1 and no closer to goal 2?
If so increase the 'thumbs up' value for the movement of this piece otherwise decrease it.
Do the same for the oppositions piece
Does this get us closer to goal 1 and no closer to goal 2?
If so increase the 'thumbs up' value for the movement of this piece otherwise decrease it.
Loop

You could set the recursive level, i.e. how far ahead do we look.

The further ahead you look, the harder the program will be to beat.


Almo(Posted 2004) [#9]
My Othello minimax algo is available, but it's in C++. Perhaps I should rewrite it into Blitz... He's actually pretty good.


puki(Posted 2004) [#10]
Just a "puki" hint - there is a fair amount of Visual Basic chess code around - it would probably be easier to convert this rather than C++ code. I downloaded a fair amount, but I can't be bothered with it.

Actually, it is sometimes quite uplifting to go through Visual Basic code forums to see just how powerful Blitz3D is compared to it (or at least easier to do something decent). Have a look at some of their 'Block-Rockin code' and think to yourself 'they're having a laugh, surely?'. There is some interesting stuff in there though - you just have to trawl through it for hours.


Shambler(Posted 2004) [#11]
I would imagine some of the VB/DirectX code blows blitz out of the water?


Glorified_Monkey(Posted 2004) [#12]
There is an example of chess AI in Blitz over at BlitzCoder.com. It was done by Grim123 his coding style is atrocious but I think the AI is actually pretty good(havnt gone over it in-depth because the game is 250,000+ lines of code).

Gabe