GithubHelp home page GithubHelp logo

strryke / betafish Goto Github PK

View Code? Open in Web Editor NEW
96.0 6.0 10.0 1.62 MB

A chess engine and AI move finder written in Javascript. Beats Stockfish level 6 on Lichess.

Home Page: https://betafish.gavinong.com

License: MIT License

JavaScript 94.38% HTML 2.33% CSS 0.13% SCSS 3.16%
chess chess-ai chess-engine javascript minimax

betafish's Introduction

Betafish

Betafish

Betafish - An amalgamation of AlphaZero and Stockfish.

Play it here.

Read more about it on my blog.

Introduction

Betafish is a chess engine and AI move finder written in Javascript, based on the Negamax algorithm. It beats Stockfish Level 6 on Lichess, and I estimate its around 1800-2000 Elo, depending on the thinking time afforded.

Features

  • Negamax algorithm with alpha-beta pruning
  • Move ordering using the MVV-LVA heuristic
  • Principal variation search
  • Quiescence search
  • Iterative deepening
  • Piece-square tables
  • Tapered evaluation

This enables Betafish to search to a depth of 7-8 plies and around ~1mil possible nodes, given a thinking time of around 1-2 seconds.

Possible Improvements

  • Transposition tables
  • Zobrist hashing
  • Opening tables

Of course, re-writing this in a compiled language like C++ would be a huge improvement. I wrote it in Javacript as I wanted to deploy it as a web app, as what fun would a game be without letting your friends challenge it? However, I quickly realised the limitations, as JS is definitely not suited for these computing-intensive tasks.

Changelogs

Credits

  • Chess Engines: A Zero to One - The article that jumpstarted my journey into chess programming.
  • WukongJS - A JS chess engine, written by Maksim Korzh, who was patient enough to answer my questions, give me pointers and point me in the right direction in this journey.
  • Bluefever Software's YouTube series - A 63-part series on chess programming, which was an absolute gold mine and served as inspiration for the bulk of the chess engine.
  • Chess Programming Wiki - A great resource for chess programming.
  • CM Chessboard - The library I used for the GUI.

betafish's People

Contributors

michaelyoon-rgb avatar strryke 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

betafish's Issues

Incorrect calculation of the next move

Hi Gavin,
Thanks so much for developing this tiny but powerful engine.

I have been enjoying using it, however, today I noticed that the engine calculates the next move of the below position very much incorrectly.
Position: 2k4r/2p1bpp1/p7/1p2n2b/3pPP2/P2P3q/1PP4N/R3QRK1 b - f3 0 24

I checked it with the two engines below and they didn't suggest that move even with the lowest rating (1300):

I also maxed "thinking time", but got the same result.
I am not sure if you answer this type of question, but thought I ask anyway since it looks like a bug.

Appreciated!

Browser chess championship

Fantastic work!

An idea popped up while testing it. How about organizing browser chess chanmpionship. Instead of chess engines, it is browsers competing with the same chess engine (betafish). The reason it would work is mainstream browsers (Chrome/Firefox/Safari) have different implementations of javascript engine which would produce a difference in performance with a fixed time allotment (say 1s).

That way we could get Browser Elo!

makeAIMove doesn't make move

Issue: Upon calling game.makeAIMove on a game with FEN of rrrrkrrr/rrrRrrrr/8/8/8/8/RRR1RRRR/RRRRKRRR b Qq - 0 0 It results in the variable bestMove to be 0 in the function. You can test this on the betafish.js website where after you set the FEN when you click "AI Move" nothing happens and no pieces are moved.

After digging, I found that the early return was due to the time being exceeded in the CheckUp function. However I still don't know how to resolve this problem, and for the FEN above, increasing the time to 200s didn't resolve the problem

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.