Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
166
rated 0 times [  170] [ 4]  / answers: 1 / hits: 20569  / 15 Years ago, wed, january 13, 2010, 12:00:00

Is there any Chess game API , purely written in JavaScript ? No Flash!
Anybody know the algorithm(in general) used in Chess games ?


More From » algorithm

 Answers
4

How does a chess algorithm work?:




What a chess computer tries to do is
generate the board-position tree five
or 10 or 20 moves into the future.
Assuming that there are about 20
possible moves for any board position,
a five-level tree contains 3,200,000
board positions. A 10-level tree
contains about 10,000,000,000,000 (10
trillion) positions. The depth of the
tree that a computer can calculate is
controlled by the speed of the
computer playing the game. The fastest
chess computers can generate and
evaluate millions of board positions
per second.



Once it generates the tree, then the
computer needs to evaluate the board
positions. That is, the computer has
to look at the pieces on the board and
decide whether that arrangement of
pieces is good or bad. The way it
does this is by using an evaluation
function. The simplest possible
function might just count the number
of pieces each side has. If the
computer is playing white and a
certain board position has 11 white
pieces and nine black pieces, the
simplest evaluation function might be:



  11 - 9 = 2 


Obviously, for chess that formula is
way too simple, because some pieces
are more valuable than others. So the
formula might apply a weight to each
type of piece. As the programmer
thinks about it, he or she makes the
evaluation function more and more
complicated by adding things like
board position, control of the center,
vulnerability of the king to check,
vulnerability of the opponent's queen,
and tons of other parameters. No
matter how complicated the function
gets, however, it is condensed down to
a single number that represents the
goodness of that board position.




Source.



For building your own javascript 'engine' that's able to play chess at a basic level check Step by Step Javascript Chess with CPU oppo



If you scroll down it contains the source code of this, must say very limited, chess engine purely based on javascript. It also has a working version of the game to try out and all the necessary resources for building your own.



Some useful resources:




[#97846] Sunday, January 10, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kevonmoisesf

Total Points: 693
Total Questions: 101
Total Answers: 128

Location: Reunion
Member since Mon, Dec 28, 2020
3 Years ago
kevonmoisesf questions
Sat, Jan 23, 21, 00:00, 3 Years ago
Tue, Feb 18, 20, 00:00, 4 Years ago
Wed, Jun 12, 19, 00:00, 5 Years ago
;