Is there any Chess game API , purely written in JavaScript ? No Flash! Anybody know the algorithm(in general) used in Chess games ?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
How does a chess algorithm work?:
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:
For algorithmic discussion, try the Chess Programming Wiki.
Techniques suited to serious chess engines are not necessarily right for web based games. Real chess engines run orders of magnitude faster, using multi-megabyte opening books and spending minutes or hours on each turn. A real chess engine will search deeper than 12 ply, while javascript won't get far past 6 ply in reasonable web time. Therefore something like a piece-square oracle, which has diminishing and possibly negative returns as search deepens and is consequently well out of fashion in chess programming circles, is arguably well suited to a javascript engine. If you do what people were doing in the 80s, you will end up with a snappy and manageable engine that will beat most visitors.
And of course you don't really want to look up what other people are doing. Just make sure you have some variation of a alpha-beta search, then tweak your evaluation function and everything else as you see fit.
In 2002 and 2012 I wrote then rewrote p4wn, a small public domain javascript engine. It uses alpha-beta and a piece-square oracle. It is probably weaker than Garbochess-JS, but then Garbochess has an opening book that is bigger that the entire p4wn engine.
The Computer Chess Blog documents the creation of a C# chess engine. It's not JavaScript but the syntax is similar enough that you might get a good understanding of the different chess engine components.
Also if you want your chess engine to be web enabled you might want to consider using C# with a Silverlight GUI. You will get better performance from .NET than you would with JavaScript. As you will learn this will translate into a stronger (deeper searching) chess program. A good example of Silverlight Chess can be found at GeeksWithChess.com