Posts

Showing posts from February, 2017

grandmaster level chess AI using python - Part 3 - Some additional thoughts

Image
Architecture of a Chess AI (note: the writing below is mostly stream of consciousness and hasn't been revised yet) A pretty typical architecture for a game playing AI consists of two components, a heuristic algorithm  and tree search. The heuristic algorithm is basically the equivalent of human intuition.  Intuition is something that is learned from experience.  As we experience more of the world around us, we become wiser and learn to make quick and accurate judgment calls just from a few quick glances.  For example, a seasoned car mechanic can quickly diagnose whats wrong with a car after having inspected it for a few minutes. A seasoned VC investor can quickly identify good startups to invest in just by having a brief conversation with the founders.  If they have decades of experience, then they can quickly make these judgment calls although they may seem biased from an outsiders perspective. The tree search aspect of a game playing AI is the logical co...

grandmaster level chess AI using python - Part 2 (the code)

Image
In continuation of part 1, I will now building my chess AI in python.  As mentioned before, my goal is to create a chess AI at the Grandmaster level (elo > 2500) Here is the code for the chess AI. https://github.com/luweizhang/chess_ai Key components of the chess game / AI: Python Classes: ChessGame instantiates the chessboard and pieces keeps track of whose turn it is RulesEnforcer Logic for how all the pieces move, castling Makes sure you cant make illegal moves Used in the chess AI to generation possible positions ChessAi Tree generator generates the tree of position moves Position Evaluator evaluates the quality of chess positions Minimax Determines the optimum move from the chess tree ChessDB Opening database Explanation of the tree generator: The tree generator component of the chess AI generates the possible future board positions based on the possible moves that the pieces can make.  At any given position, there are o...