|
Shhhhhh....keep that to yourself
|
|
|
|
|
Ah, chess...
I think about it once in a while. Remember this question from October? The Lounge - CodeProject[^]
I think of it this way:
0) There are sixty-four spaces on a chess board
1) Each space may be unoccupied or occupied by one token (I'll try not to say "piece")
2) There are six types of token: King, Queen, Bishop, Knight, Rook/Castle, Pawn
3) There are two colors of token: Black, White (usually)
4) That makes twelve distinct token values, plus we can use a "null" token to represent an empty space, for a total of thirteen values
I chess position can therefore be reduced to a sixty-four digit base-13 value.
Windows calculator calculates 13^64 as 1.9605347643076107333065976042357e+71 .
A great many such values will not represent a valid chess position.
So all you need to do is enumerate from zero to 1.9605347643076107333065976042357e+71, eliminate the invalid values and determine a pair of "best next position" values (one for black, one for white), and store them. Then during a game, a simple look-up is all that is needed to select your move.
It becomes boring really; hardly any challenge at all.
Here's what I wrote in October; this is the hard part:
[System.ComponentModel.DescriptionAttribute("Chess piece definition")]
public enum Piece
{
[System.ComponentModel.DescriptionAttribute("No piece, empty square")]
None = 0
,
[System.ComponentModel.DescriptionAttribute("Piece has a special or limiting movement rule")]
SpecialMask = 1
,
[System.ComponentModel.DescriptionAttribute("Piece can move only in ranks or files")]
OrthogonalMask = 2
,
[System.ComponentModel.DescriptionAttribute("Piece can move diagonally")]
DiagonalMask = 4
,
[System.ComponentModel.DescriptionAttribute("Black chess piece")]
BlackMask = 8
,
[System.ComponentModel.DescriptionAttribute("Knight")]
Knight = 1
,
[System.ComponentModel.DescriptionAttribute("Rook")]
Rook = 2
,
[System.ComponentModel.DescriptionAttribute("Pawn")]
Pawn = 3
,
[System.ComponentModel.DescriptionAttribute("Bishop")]
Bishop = 4
,
[System.ComponentModel.DescriptionAttribute("Queen")]
Queen = 6
,
[System.ComponentModel.DescriptionAttribute("King")]
King = 7
}
|
|
|
|
|
Actually all chess programs are combining two things...
1. Basic knowledge of the chess rules
2. A lookup of pr-recorded strategies (for opening, play and end-play separately in most cases)
The reason for that is that there is on really best-move for most parts of the game...Chess is not only about moving the pieces around but to build a defense/offense strategy that will provide you not only with small victories but winning the war too...
There is a few estimates of the number of possible chess games (between 10^50 to 10^120) and they say there is more chess games than atoms in the universe (which of course has no base and only effective as a way to tell that there are unimaginably large number of games)...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Your analysis doesn't allow for en passant or "You can/can't castle"...
I'm retired. There's a nap for that...
- Harvey
|
|
|
|
|
Yes it does:
[System.ComponentModel.DescriptionAttribute("Piece has a special or limiting movement rule")]
SpecialMask = 1
Knight, King, and Pawn all have that Flag.
|
|
|
|
|
Having the flag doesn't complete the problem. The state of a board position needs to include whether an en passant move or a rook/king move has recently or already taken place. Just knowing that a move could have taken place doesn't work.
[... not sure what you mean about knight. I think you meant rook.]
I'm retired. There's a nap for that...
- Harvey
|
|
|
|
|
Pfft. That's details.
I meant Knight. Rooks have nothing special other than being at the mercy of the King during a castling move. The goal of that exercise was merely to assign 4-bit values to the tokens in a "logical" manner. I have no ambition to implement the system as described.
|
|
|
|
|
Kornfeld Eliyahu Peter wrote: the (almost) endless number of variations of games
Relax and play[^]
What we got here is a failure to communicate
|
|
|
|
|
How about a nice game of chess?
|
|
|
|
|
Amazing that I would have never known either of them had died, if it weren't for the breaking news reporters here on CP.
|
|
|
|
|
Aye, well, um .... oops![^]
I am not a number. I am a ... no, wait!
|
|
|
|
|
Still dead...
New version: WinHeist Version Tequila, the nigh time, snuffly, sneezing, how the hell did I end up on the bathroom floor medicine.
|
|
|
|
|
Please no, say it ain't so...
|
|
|
|
|
Just wiped my Yahoo account (90 days and counting)...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I cant do it - I am too sentimental. My first e-mail nearly 20 years.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
|
Mine was my, still active, hotmail account that must be somewhere near that.
veni bibi saltavi
|
|
|
|
|
Nah Compuserve died some time ago.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Oh, that's all... I was afraid that Bowie might have died, there were rumours.
|
|
|
|
|
It's worse than that, Leslie Nielsen has died!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You just reminded me to check my Yahoo Mail account, which I haven't done in at least 6 months. Based on past history, I was expecting hundreds of unread items.
Surprisingly, it only has 12 emails, all spam, all dated from December 11 onward, which is probably not a coincidence. They've either gotten a lot better, or they now just blindly delete everything older than a month (inbox included, to which I say WTF).
|
|
|
|
|
Is, unlike David Bowie, still alive.
veni bibi saltavi
|
|
|
|
|
Sadly the pool of people who will understand this grows ever smaller.
|
|
|
|
|
But at least the waters warm.
veni bibi saltavi
|
|
|
|
|
Don't worry, some names will never be forgotten as long as CP is there - He who shall not be named, Pumpkinhead, Adnan Siddiqui, Dalek Dave....
Cheers,
विक्रम
"We have already been through this, I am not going to repeat myself." - fat_boy, in a global warming thread
|
|
|
|