Coder Social home page Coder Social logo

chessneuralnet's Introduction

Chess AI

A chess AI, with with different algorithms of increasing intelligence.

Play live version here: https://chess-neural-net-zain0.herokuapp.com/ Play live version with some extra html and css: https://codepen.io/zainmer/pen/jOOBjvv

See my blog post about implementation here: https://zm2231.github.io/coding/2019/10/23/test.html

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development. See Deployment for notes on how to deploy the project on a live system.

Prerequisites

You will need to have Node.js and npm installed. For instructions on installing Node, please visit NPM's documentation on installing Node.js.

Installing

You can run npm's initialization to install dependencies from package.json.

npm init

How to Play

When playing, I recommend having your browser's console open to issue commands and view the computer player's 'thinking' through each move.

Play Against Computer

To play against the computer, simply make a move. You will play as the white side. The computer will then make a move.

The computer is currently set to look 3 moves ahead using minimax with alpha beta pruning.

Computer vs Computer

If you'd like to have the computer play the computer, you can do so with this command in your browser's console, setting the algorithm you'd like to use, and each computer player's 'skill' level.

playGame(algo=4, skillW=2, skillB=2)
// algo=
// 1 - random
// 2 - Best move, one move ahead
// 3 - Best move, n moves ahead, minimax
// 4 - Best move, n moves ahead, minimax with alpha beta pruning (Faster)
// skillW and skillB are how many moves ahead to look

skillW and skillB only work with alogs 3 & 4. The skill level is what sets how many moves ahead each player will look.

Algo 3 does not use alpha beta pruning, so setting skill levels greater than 2 will make move times very long.

Algo 4 uses alpha beta pruning, so you can set skill level up to 3, maybe even 4. But beyond that, move times will be very long.

Deployment

You can run this locally with Node.js, and visiting http://localhost:5000.

node app.js

You can also easily deploy this to a server. It is ready to be deployed to Heroku, with a Procfile included. Instructions from Heroku

Built With

Authors

  • Zain Merchant - Initial work - zm2231

License

This project is licensed under the MIT License - see the LICENSE file for details. Some files have their own licenses, as described in 3rd Party Software below.

3rd Party Software

See LICENSE-3RD-PARTY file for full licenses

Todo

  • Implement Negamax
  • Implement sorting function for possible moves to optimize alpha beta pruning
  • Better implementation of Express
  • Add an element of machine learning
  • Improve interface
  • Refactor code
  • Get this to work in Safari
  • The AI is terrible at beggining, but is amazing at endgame. Fix somehow?

chessneuralnet's People

Contributors

zm2231 avatar

Watchers

 avatar

chessneuralnet's Issues

Issues with Safari

In Safari, the board looks like it refreshes after every move. It does the same thing on mobile as well (iOS 13 - iPhone 7-XR. Safari, Firefox, Chrome, Cake). Figure out what's wrong and see if there's a fix.

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.