View Full Version : Flash chess AI
gonzos
12-06-2008, 10:58 PM
Hi everyone.
These days I'm trying to develop flash chess game. It's gona be a simple game-human vs. computer.
I start to code from beginning-make chessboard, chess positions, make human moves, update and saving current chessboard etc.
This (http://www.snapdrive.net/files/569921/DEMOS/board3.swf) my current work, and this is source (http://www.snapdrive.net/files/569921/DEMOS/board3.rar) (AS2, FlashCS3)
Everything works fine but when I was try to make AI for computer moves I stuck!
So, I know the best chess AI algorithms already done and probably I can't do better. I need start point for search (minimax, alpha-beta) algorithms. In theory I know what to do:
1. check who can make move (pawn, queen, rook...)
2. check legal moves (if field empty, no king check etc.)
3. search for the best move
Like I'm said I need suggestions, start point, piece of code- not finised game code ( I'll do it by myself)
Some of this looks good to me:
http://www.gamedev.net/reference/articles/article1208.asp
http://www.gamedev.net/reference/list.asp?categoryid=163
gonzos
12-10-2008, 02:54 PM
Thanks, this is very usefull links. I hope I'll finish the game.
One thing to worry about specific to Flash is that it's not very good at threading big computations, so if you have something that's going to take several seconds to run, you might want to come up with a way to break it up into smaller sections that can run off a timer, just for improved user experience. And AS3 would have been better because you can make it run a lot faster than AS2 if you use typed variables and stuff.
gonzos
12-12-2008, 12:56 PM
I still need help to create minimax search algorhytm.
Theoretic I want to do next:
Said that we are start game and white (human player) move his pawn like this:
br-bk-bb-bq-bK-bb-bk-br
bp-bp-bp-bp-bp-bp-bp-bp
0--0--0--0--0--0--0--0
0--0--0--0--0--0--0--0
0--0--0--0--wp--0--0--0
0--0--0--0--0--0--0--0
p--p--p--p--0--wp--wp--wp
wr-wk-wb-wq-wK-wb-wk-wr
So, now for search my root node of search tree is-wp on E4
First i search for black possible moves-only can moves black pawns & black knights and its 20 moves (16 for pawns, 4 for knights).
It's second tree node in search tree, now white calculate possible moves and it's now 20+ moves for white, then black check move etc.
Say it that I want calculate (search for only 3 future moves) and stop searching. I don't have idea how to evaluate tree nodes to get best min and best max value.
How can I evaluate tree?
My first link was a general description of board evaluation in chess. I don't have anything more precise without googling for it.
gonzos
12-14-2008, 10:58 PM
I appreciate your links and I'm learn a lot from there, but now I'm in actionscript reallity.
Main problem is how to create search tree?
Idea:
1. root node is 1st white move (say it E4)
I store it in multidimensional array like movesArray[a-1st move][-all black moves] etc. where [all black moves] is second node and so on.
The posibble moves for white E4 is:
br-bk-bb-bq-bK-bb-bk-br
0--0--0--0--0--0--0--0
bp-bp-bp-bp-bp-bp-bp-bp
0--0--0--0--0--0--0--0
0--0--0--0--wp--0--0--0
0--0--0--0--0--0--0--0
wp-wp-wp-wp-0-wp-wp-wp
wr-wk-wb-wq-wK-wb-wk-wr
or
br-bk-bb-bq-bK-bb-bk-br
0--0--0--0--0--0--0--0
0--0--0--0--0--0--0--0
bp-bp-bp-bp-bp-bp-bp-bp
0--0--0--0--wp--0--0--0
0--0--0--0--0--0--0--0
pw-pw-pw-wp-0-wp-wp-wp
wr-wk-wb-wq-wK-wb-wk-wr
or
br-0-bb-bq-bK-bb-0-br
bp--0--bp--0--0--bp--0--bp
bk-bp-bk-bp-bp-bk-bp-bk
0--0--0--0--0--0--0--0
0--0--0--0--wp--0--0--0
0--0--0--0--0--0--0--0
pw-pw-pw-wp-0-wp-wp-wp
wr-wk-wb-wq-wK-wb-wk-wr
or more combination black knights & black pawns, so what choose for the second node?
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.