Skip to content

C++ header-only library for generating legal chess moves

License

Notifications You must be signed in to change notification settings

gianmarcopicarella/virgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virgo


Sulu logo


GitHub license GitHub tag (latest SemVer) GitHub contributors


Virgo is a highly extensible and easy to use c++ header-only library for legal chess moves generation.

Features:

  • Easy to integrate and use in any chess engine
  • Bitboard representation paired with a fast lookup array
  • Non-sliding attacks bitboards generated by fast lookup (Knights and King) and binary shift (Pawns)
  • Sliding attacks bitboards generated from pre-computed Kindergartner bitboards
  • Make-take move functions supplied with a simple Chessboard object

Usage

Download the repository and include Virgo's header into your source code. In order to include Virgo's implementation correctly, it is required to define the macro VIRGO_IMPLEMENTATION before the #include directory.

#define VIRGO_IMPLEMENTATION
#include "virgo.h"
#include <iostream>

int main() {
    virgo::virgo_init();

    std::vector<uint16_t> legal_moves = {};

    virgo::Chessboard board = virgo::position_from_fen("n1n5/PPPk4/8/8/8/8/4Kppp/5N1N w - - 0 1");
    std::cout << board << std::endl;

    virgo::get_legal_moves<WHITE>(board, legal_moves);

    for(uint16_t & move : legal_moves) {
        std::cout << virgo::string::move_to_string(move) << std::endl;
    }

    std::cout << "\ntotal moves: " << legal_moves.size() << std::endl;

    return 0;
}

Future improvements

  • Magic bitboards lookup table
  • Move representation size to 16bit
  • Avoids illegal moves by design

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contribution you make to Virgo is greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Virgo is released under the under terms of the MIT License.