View Full Version : Flash Chess Game
Hi there,
Is there anyone knows where can I find .fla files of a chess game?
Kind Regards,
SAC
olganunes
07-13-2001, 07:44 PM
I think smashing ideas did a checkers game way back in the day for the release of flash 4, but I'm sure it has similar principles to what you're looking for?
I don't know if the fla is available, but it seems possible, since it seemed to be a project for the flash 4 release.
If you do find a chess fla, let me know.. I would be curious, my husband has been idly working on a chess/knight's tour engine. (only gotten as far as moving the knight piece accurately across the board when you click on it... )
Jesse
07-14-2001, 03:44 AM
I've made chess and checkers. not only that but my checkers has a one player mode which plays against you with 3 levels of difficulty. so I can encourage you and say it is possible, but since these are corporate projects I can't give you the source or show you the products yet.
mordocai
08-24-2006, 11:02 PM
After about 5 years of no posts this thred lives again!
Jesse, if you dont mind me asking, do you know of any books on how to make a chess game? I've ben searching for the longest time, and still got nothing....
Jesse
08-25-2006, 12:29 AM
Wow, old thread indeed.
I made this chess game before I completed my Computer Science degree. Later, in that degree, I took a subject on Artificial Intelligence and we had to make a game similar to chess, but simpler. The techniques we were taught ended up being more advanced versions of what I had figured out or learned online myself.
The only technique I really I remember is "Alpha Beta Recursion" but they all basically revolve around calculating every possible move from the current board state, then every subsequent possible move from that board state, then every move from that state, until a certain amount of time has elapsed.
Each board state is given a score (e.g. if there are fewer enemy pieces on the board, you've captured a piece, so the score should be higher than if you haven't, so long as you aren't in check, or something) and you sum the scores to determine which 'path' is the smartest, then make the first move towards that path. That's pretty brute force, and there are nice little twists you can ad to make your algorithm faster or smarter; e.g. avoid even calculating something which will mean you move into check, etc.
You can probably find heaps online, or grab a good quality, generalist Artificial Intelligence book from your local library because it will discuss these kinds of AI methodologies.
Good luck.
philliptune
04-27-2009, 07:08 PM
Once again, new life must be breathed into this thread. I wanted to see if anyone has heard of/found any scripts for doing a 2P chess game since the last discussion.
Back in ought 4 (2004 for you youngins) I wrote a VB.NET code for a functional 2P chess board; it only lacked a "check-mate" checker (or for that matter, a "don't put yourself in check-mate" checker). 75 pages worth of code and 2 solid weeks sucked out of my life because of my ignorance of better methodology. I'm aiming to redo it in Flash to get a better grasp on puzzle game writing (and because I love chess).
I understand there are 2d arrays that would be helpful to streamline programming. Believe it or not, in VB i had to declare something like 8 sub-variables for all 64 square variables... (what's the math on that?). Starting to make sense why my code was 75 pages long?
Anyways, any update would be appreciated.
runawayprisoner
04-27-2009, 08:01 PM
Well, can't give you any source code... yet, because most of my works are under NDA.
But I can discuss the techniques with you. First, to represent the entire board, make a 16-element integer array. Each integer will represent four consecutive squares on the board, 4 bits for every square. (this means every 2 elements in the array will represent a row in the game board)
Each 4 bits will have the following values:
[decimal value] [binary form] [purpose/description]
0 000 no chess piece is in this square
1 001 a pawn is in this square
2 010 a knight is in this square
3 011 a bishop is in this square
4 100 a rook is in this square
5 101 a queen is in this square
6 110 a king is in this square
7 111 reserved
The 4th bit is used as a flag to indicate whose chess piece this is. So for instance, if the chess piece belongs to the first player, the 4th bit is 0, and if the chess piece belongs to the second player, the 4th bit is 1.
For calculating the next moves, I use another integer array with 4 elements.
Every 2 bits represents a state of the game board.
[decimal value] [binary form] [purpose/description]
0 00 no movement, nothing
1 01 you can move this chess piece
2 10 you can move your chess piece to this square
3 11 you can take this chess piece (or it's possible for you to make a move where you can take this chess piece)
Thus one 32-bit integer will contain the states of 16 squares, and 4 integers will contain the states of the entire game board.
And then you can calculate ahead as much as you want, since one state is just 4 integers. Usually, in a 2P game, you just want to calculate that once, or twice if you want to check for potential checkmate situations. But if it's an AI game, in the worst case scenario, you have 4 * 64 ^ n (where n is the number of moves to calculate ahead), which is... about 1048576 integer variables for three moves. Thus in the worst case scenario for three moves ahead, you'd use up 2MBytes of memory to store the state.
But that's for efficiency. The actual implementation might be a bit more complicated due to that you have to decode all of that in real-time, and then your AI would have to analyze them. Good news is... Flash deals with all of that quite fast since they're just integers. The problem would then lie in your analysis function rather than the decoding functions.
Anyway, if A.I. is of no concern, then after you've written the decoding functions, and the one-state calculator, you're pretty much done.
Alternatively, to cut short the decoding functions (and reduce processing overhead), you can store the states and the gameboard as raw integers, one for every square (so the arrays to store them would have 64 elements). Since we have up to hundreds of megabytes available on computers nowadays, a couple of megabytes would not hurt. It's a small trade-off in terms of memory usage, but will be a huge help with performance. The prior should be used only for developing on mobile devices where memory usage is quite an issue.
Edit: and another technique to calculate potential checkmate is... instead of calculating the next state (which means you have to calculate it for every piece), just calculate it for the king piece. Probably one more function to write (and maybe up to half a page of codes) but it's worth it.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.