Skip to content

MatTheTab/PikeBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PikeBot

Repository for an AI-based chess bot designed to exploit human gameplay weaknesses, set up traps, and play much more aggressively than the vast majority of the currently available chess bots. PikeBot utilizes score evaluations generated by Stockfish to make intelligent, human-like decisions, resulting in more dynamic and exciting chess games. What sets PikeBot apart from other chess bots is its commitment to utilizing human strategic weaknesses rather than pursuing optimal gameplay, leading to more engaging gameplay.

The current version of PikeBot was trained on 500 000 publicallly available games from Lichess, and showcases promising results in the task of beating human players in the fewest possible moves. When starting from a disadvantageous position, the engine has been shown to perform better than Stockfish, requiring fewer moves to win against human opponents. To see details look for the lichess_games_results section.

Original Data

Lichess Dataset

Trained Models

Google Drive Folder with Saved Models

Play with PikeBot

Lichess PikeBot

Test your bot recognition skills

Website for Human vs Bot Recognition

Example Data

Example Data on Google Drive


Developer Notes

  • Data -> raw PGN data, needs to be converted to .npy files
  • Preprocessed_Data -> data read from PGN files
  • Model_Data -> Data which can be directly fed into the model, normalized/standardized and generally cleaned data from Preprocessed_Data

Project directory structure:

PikeBot
├── alternative_approaches
│   ├── additional_experiments_2
│   └── additional_experiments_NNUE
├── archive
|   └──Stockfish - Processing Tests
├── best_models
├── evaluation
|   └──games
├── experiments-results
├── human_move_prediction
├── lichess_games_results
├── lichess-bot-master
├── model_loading_data
├── pikebot
├── tests
├── training_logs
├── utils
├── .gitignore
├── conda_requirements
├── config.json.default
├── environment
├── LICENSE
├── README
└── requirements

Repo explanation

  • utils/ (in any folder): folder contains code later imported into notebooks
  • logs/ (in any folder): logs of training process
  • alternative_approaches/: Contains different experimental approaches, including additional experiments and NNUE-based trials.
  • archive/: Stores previous test results and other legacy files, including Stockfish processing tests.
  • best_models/: Contains the best-performing trained models used in the project (currently moved to the google drive, look for link in the previous sections).
  • evaluation/: Stores results from evaluating the model, including played games.
  • experiments-results/: Records outcomes of various experimental runs performed on the model.
  • human_move_prediction/: Dedicated to training models that predict human moves based on given positions.
  • lichess_games_results/: Stores results of games played on Lichess, results show PikeBot outperforming Stockfish against human opponents.
  • lichess-bot-master/: Contains the implementation for interfacing PikeBot with Lichess.
  • model_loading_data/: Holds data needed for loading and running trained models efficiently.
  • pikebot/: heuristic implementations
  • tests/: Contains unit tests and integration tests for validating different components of the bot.
  • training_logs/: Stores logs from training runs to analyze model performance over time.
  • utils/: Contains utility scripts and helper functions used across different parts of the project.

Data Structure

Default dataframe columns explanation:

Column Name Explanation Expected Values
human if the move was made by a human or randomly, expected model output True/False
player name of the player or "bot" if the move was made by a bot name of the player like: "cixon123"
elo player's ELO score integer value, e.g. 1397
color color of the player "White" or "Black"
event event of the game Event as defined in Lichess, e.g. Rated Classical game
clock how much time is left in the game floating point number representing time left in a game, e.g. 64.0
stockfish_score_depth_{depth} score for a currently playing player judged using stockfish of chosen depth in {depth} Stockfish score as int, e.g. 744
stockfish_difference_depth_{move_num} difference between last human-made position as evaluated by stockfish and the position after making a move, i.e. how advantageous/disadvantageous a move was Stockfish score as int, e.g. 744
past_move_{move_num} past move saved as bitboard to provide context for the model bitboard representing board state from past turns, shaped (76, 8, 8)
current_move currently performed move, expected input to the model along with optional context from previous columns bitboard representing board state after the current human/bot move, shaped (76, 8, 8)
current_move_str Forsyth–Edwards Notation (FEN) representation of the current board state String representing the board state (example shortened here) - , e.g. r2q1rk1/...

How to Retrain the Human Move Recognition

To retrain the human move recognition model, follow these steps:

1. Set Up the Environment

Ensure that all required dependencies are installed. You can set up the environment using Conda:

conda env create -f conda_requirements.yml
conda activate pikebot_env

--- Alternatively ---

download the environment:

conda env create -n pikebot_env --file environment.yaml
conda activate pikebot_env

--- Alternatively ---

Install the dependencies on Python 3.10:

pip install -r requirements.txt

2. Use the run.py file

Move to the human_move_prediction directory. Now, you can simply run the run.py file, the results will be saved in the corresponding folders and notebooks (CUDA GPU heavily recommended):

python run.py

3. Advanced: Customize Training

If you wish to modify the training process, refer to the Jupyter notebooks in the project.

For adjusting data processing, refer to the preprocessing scripts. For model architecture modifications, check the training notebooks inside human_move_prediction/. If you want to explore or modify the dataset, refer to the Original Data section for access to raw game data.

About

AI-based chess model to simulate human-like behavior, aggressive and intelligent play.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •