Skip to content

GeekJC/Simple-chess-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

+--------------+
|  chess A.I.  |
+--------------+

--------------------
Directory structure:
--------------------
* algo.h & algo.cpp: the actual implementation of MINMAX and alpha-beta pruning
    * algo.h: define all the algorithm-related configurations, you can change the parameter value here.
              For example: use different coefficients for different pieces in the evaluation function

* rule.h & rule.cpp: the implementation of the chess rule, including:
    * regular rules for KING, QUEEN, BISHOP, ROOK, KNIGHT, PAWN
    * special rules for PAWN:
        * enpassant
        * taking / non-taking
        * promotion (to queen)
    * special rules for KING:
        * castling with ROOK
    * NOTE:
        * when PLAYER is inputing his next move, all the above rule applies
        * when A.I. is doing search, it follows most of the above rules, except castling.
          The reason is because, castling itself has very strict requirements, so:
            * its occurance is rare --> not crucial to A.I.'s evaluation
            * its computation is expensive (has to check sevaral times if the KING is checked) --> not suitable for evaluation function

* util.h & util.cpp: utility functions for printing and debugging

* test_board.h: board configurations for testing purpose


------
Usage:
------
* To build: type `make` in terminal
* To play:
    * A.I. is holding pieces at the upper part of the board
    * when the game starts, PLAYER is moving first (To change this behavior, change the "INIT_MOVE" macro in rule.h)
    * Player should input 4 integers to move his piece (from_row, from_column, to_row, to_column)
    * After every move, the following is printed out:
        * board
        * whether a side is checked
        * the time spent by A.I. (if it is the Player's turn, the number will be -1)
    * program exits when player has winned or lost

About

HKU AI course mini project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published