All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Games
How many openings? (Posted on 2002-10-27) Difficulty: 5 of 5
How many possible openings are there in the game of chess, if we define an that opening consists of each player making their first 3 moves?

(With one move there are 400 possible openings)

See The Solution Submitted by James    
Rating: 3.5714 (14 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Programming | Comment 6 of 17 |
So if one were to program a solution to this...

Define a coordinate on the board (x,y) as (x-1)+8(y-1) - giving us values from 0 to 63.

Ennumerate all the possible pieces from 0 to 31. We can assume that each piece is unique because a pawn cannot make it across the board in 3 moves.

A gamestate therefore can be considered an array from 0 to 31 of integers that can have values from 0 to 64. (64 meaning the piece is captured - it kinda forces us into an extra bit of storage, but since oh well)

We will also associate a "counter" with each gamestate: starting at 0, it will be incremented for each turn taken. (Have it increment for each side: 0 initial, 1 after white move, 2 after black move, etc.)

We will also need to have a queue mechanism able to store GameStates.

The initial GameState (with the pieces properly arranged) is pushed into the queue. Then we go into a loop.

while queue is not empty {

    get next GameState from queue;
    for every uncaptured Piece in the GameState {

      for every legal Move {

        if this is GameState is in third turn {

          increment globalCounter;

        } else {

          create newGameState resulting from Move;
          increment turn counter on newGameState;
          push newGameState into the queue;

        }

      }

    }

}


Of course finding legal moves for a piece may be a bit complicated...


Problems? Analysys? Suggestions?
  Posted by levik on 2002-10-28 13:26:30

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (16)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information