GithubHelp home page GithubHelp logo

zeyu2001 / chess-ai Goto Github PK

View Code? Open in Web Editor NEW
235.0 8.0 102.0 51 KB

Simple chess AI in JavaScript. Uses the chess.js and chessboard.js libraries.

Home Page: https://zeyu2001.github.io/chess-ai

License: MIT License

HTML 13.36% CSS 0.55% JavaScript 86.09%
chess chess-engine chess-ai chessboard javascript

chess-ai's Introduction

chess-ai

A chess engine by someone who doesn't know how to play chess.

About

chess-ai is a simple chess AI in JavaScript.

The primary concern of chess-ai is the decision-making part of the application. All functionality outside the scope of the AI are implemented using external libraries:

  • Chessboard GUI: Using the chessboard.js API
  • Game Mechanics: Using the chess.js API

The AI uses the minimax algorithm, which is optimised by alpha-beta pruning.

The evaluation function uses piece square tables adapted from Sunfish.py, and eliminates the need for nested loops by updating the sum based on each move instead of re-computing the sum of individual pieces at each leaf node.

A global sum is used to keep track of black's evaluation score after each move, which is used to display the 'advantage' bar.

How to Play?

  1. Head over to https://zeyu2001.github.io/chess-ai/.

  2. Play as white by dragging a piece to your desired location. The AI plays as black. The AI's minimax search depth (which is directly related to how well it will play) can be customised using the 'Search Depth (Black)' dropdown. Using a higher value will improve the AI's accuracy, but it will take longer to decide on the next move.

  3. To pit the AI against itself, click the 'Start Game' button under Computer vs. Computer. You can stop the game at any time using the 'Stop and Reset' button.

License

Use of this project is governed by the MIT License.

chess-ai's People

Contributors

huydhoang avatar zeyu2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chess-ai's Issues

Feature Suggestions

I read all explanations and that is just clear.
I loved your dev.
Questions:

  • any way to UNDO a movement (CTRL+Z) ?
  • would be great to add Human vs Human mode !

regards

Mobile Play

I created a page on my site at https://boredhumans.com/chess.php using your program, but it is hard to get the pieces to move on my iPhone. I can't drag them like on PC, I have to click the piece first (which then makes a giant sized version of it pop up which I then have to click again get off the screen) and then click where I want it to go. Any suggestions on how to improve that?

AI has no concept of stalemate

I can be heavily losing a game, and it will allow threefold repetition which results in a stalemate

It should evaluate stalemate as a score of 0

Just my two cents : )

Problem with settings

Hi, while trying the game i noticed some bugs.

  1. Initially i noticed that during the game if we change the Search depth settings then the game crashes and displays a message that it does not respond.

2)Having the choice to show us the suggested moves, sometimes he shows us in a red box the opposing pieces and not the touches that we play (white).
Screenshot_6

3)ฮ™f we choose to play the computer against the computer and then choose to display the suggested moves then it displays two red boxes throughout the game
Screenshot_8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.