# AI-Chess
Basic chess features that includes an AI for decision making in Python
# Install Guide
To install packages run in terminal (Python 3.9+):
pip install AI-Chess
# Quick Tutorial
To start the board and the AI, do the following:
>>> from AIchess import *
>>> aic = AIChess()
If you want to take a look at the board do this:
>>> print(aic.board)
If you want to get the board as a 2D list for easy use and print each row do this:
>>> [print(sub_list) for sub_list in aic.get_boardAs2DList()]
If you want to get the board as a flipped 2D list for easy use with white on top and black on bottom but with chess notation like 'a1' still being on white then print each row do this (Extra functions to support this board exist in documentation like automatically flipping the row and col to support this):
>>> [print(sub_list) for sub_list in aic.get_boardAs2DListFlipped()]
If you want change the AI algorithmic minimax depth to a higher number for better accuracy at the cost of computational requirement do this (Default: 3; Needs to be greater than 0):
>>> aic.minimaxDepth = 2
If you want to use the minimax AI to get one of the best possible moves for whoevers turn it is and use that move on the board then print the board do this (This assumes that the game isn't over for any reason):
>>> aic.makeChessMove(aic.chessAIMove()[0])
>>> [print(sub_list) for sub_list in aic.get_boardAs2DList()]
# Documentation
__init__()
Initialize the library by creating board: chess.Board which is the starting chess board in the chess library, it is public for you to use however be careful as you can break some functions and minimaxDepth: int which is the depth of the search algorithm. Higher the better but requires move computational power. Single process and needs to be > 0. Default 3.
chessAIMove() -> List[str]
Returns a list of the best possible legal_moves for whoevers turn it is in UCI however, it is possible that one or more of the entries can be the string 'claim_draw' instead of a UCI which is to indicate the desire to claim a draw like FIFTY_MOVES or THREEFOLD_REPETITION
get_whiteBlackPointsDifference(game: chess.Board) -> int
Returns the point difference between white and black where Pawn: 1, Bishop: 3, Knight: 3, Rook: 5, Queen 9
makeChessMove(uci: chess.Move | str) -> None
Needs to be at least pseudo_legal
listAllPossibleMoves() -> List[Move]
Lists all possible legal_moves for whoevers turn it is for each piece
listUCIPosPossibleMoves(uciPos: str) -> List[Move]
Lists all possible legal_moves for whoevers turn it is for the uciPos like 'a2', or 'b1'
Returns an empty List if no possible moves
reset() -> None
Resets board in chess.Board
willMoveNeedPawnPromotion(uci: chess.Move | str) -> bool
Return True if move will result in a pawn promotion, False otherwise
pieceToPieceType(result: chess.Piece | str) -> int
Return chess.PieceType as a int
rowColToUCI(rowColFrom: list[int], rowColTo: list[int]) -> str
Accepts two List[int] which is the row and col from and to locations
Returns a str which is a uci representing the inputs
uciToRowCol(uci: chess.Move | str) -> List[int], List[int]
Accepts a str which is a uci
Returns two List[int] which are the row and col from and to representing the inputs
rowColToUCIPos(row: int col: int) -> str
Accepts a row and col of a 2D list that is the chess board
Returns a uciPos which is a single position like a2 or b1 representing the inputs
uciToRowColPos(uciPos: str) -> int, int
Accepts a uciPos which is a single position like a2 or b1
Returns a row and col of a 2D list that is the chess board representing the inputs
uciToFlippedRowCol(uci: chess.Move | str) -> List[int], List[int]
Accepts a uci
Returns two List[int] which are the row and col from and to in a 2D list that is the chess board representing
the inputs but flipped so that white is on top and black is bottom
flippedRowColToUCIPos(row: int, col: int) -> str
Accepts a row and col position that has been flipped so that white is on top and black is on bottom
Returns a uciPos which is a single position like a2 or b1 representing the inputs
uciToFlippedRowColPos(uciPos: str) -> int, int
Accepts a uciPos which is a single position like a2 or b1
Returns a row and col position that has been flipped so that white is on top and black is on bottom representing the inputs
flipRowCol(rowColFrom: list[int], rowColTo: list[int]) -> List[int], List[int]
Accepts two List[int] which is the row and col from and to locations
Returns two List[int] which is the row and col from and to locations but flipped so that white is one top and black is on bottom
flipRowColPos(row: int, col: int) -> int, int
Accepts two int which is the row and col for a location
Returns two int which is the row and col for a location but flipped so that white is one top and black is on bottom
get_boardAs2DList() -> List[int][int]
Returns a 2D list that represents the chess board with white on bottom and black on top for easy use
get_boardAs2DListFlipped() -> List[int][int]
Returns a 2D list that represents the chess board but flipped so white is on top and black is on bottom for easy use
get_isWhiteTurn() -> bool
Returns a bool where True is if it is white's turn and False if it is black's turn
get_isStartOfGame() -> bool
Returns a bool where True is if it is the start of the game and False if it isn't
# Extra
For more information on how to use this project visit https://python-chess.readthedocs.io/en/latest/ where some of this project uses.
Raw data
{
"_id": null,
"home_page": "",
"name": "AI-Chess",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,chess,AI,Artificial Intelligence,game,puzzle",
"author": "mtootoonchi (Matthew Faraz Tootoonchi)",
"author_email": "<mftootoonchi@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/3e/79/0b2ca6f73ccc77b86e9ac2468f3edf4f6f96396c295d0664e971fc69481d/AI-Chess-2.0.8.tar.gz",
"platform": null,
"description": "\r\n# AI-Chess\r\n\r\n\r\n\r\nBasic chess features that includes an AI for decision making in Python\r\n\r\n\r\n\r\n# Install Guide\r\n\r\n\r\n\r\nTo install packages run in terminal (Python 3.9+):\r\n\r\n\r\n\r\n pip install AI-Chess\r\n\r\n\r\n\r\n# Quick Tutorial\r\n\r\n\r\n\r\nTo start the board and the AI, do the following:\r\n\r\n\r\n\r\n >>> from AIchess import *\r\n\r\n >>> aic = AIChess()\r\n\r\n\r\n\r\nIf you want to take a look at the board do this:\r\n\r\n\r\n\r\n >>> print(aic.board)\r\n\r\n \r\n\r\nIf you want to get the board as a 2D list for easy use and print each row do this:\r\n\r\n\r\n\r\n >>> [print(sub_list) for sub_list in aic.get_boardAs2DList()]\r\n\r\n \r\n\r\nIf you want to get the board as a flipped 2D list for easy use with white on top and black on bottom but with chess notation like 'a1' still being on white then print each row do this (Extra functions to support this board exist in documentation like automatically flipping the row and col to support this):\r\n\r\n\r\n\r\n >>> [print(sub_list) for sub_list in aic.get_boardAs2DListFlipped()]\r\n\r\n \r\n\r\nIf you want change the AI algorithmic minimax depth to a higher number for better accuracy at the cost of computational requirement do this (Default: 3; Needs to be greater than 0):\r\n\r\n\r\n\r\n >>> aic.minimaxDepth = 2\r\n\r\n \r\n\r\nIf you want to use the minimax AI to get one of the best possible moves for whoevers turn it is and use that move on the board then print the board do this (This assumes that the game isn't over for any reason):\r\n\r\n\r\n\r\n >>> aic.makeChessMove(aic.chessAIMove()[0])\r\n\r\n >>> [print(sub_list) for sub_list in aic.get_boardAs2DList()]\r\n\r\n \r\n\r\n# Documentation\r\n\r\n\r\n\r\n __init__()\r\n\r\n\r\n\r\nInitialize the library by creating board: chess.Board which is the starting chess board in the chess library, it is public for you to use however be careful as you can break some functions and minimaxDepth: int which is the depth of the search algorithm. Higher the better but requires move computational power. Single process and needs to be > 0. Default 3.\r\n\r\n\r\n\r\n chessAIMove() -> List[str]\r\n\r\n \r\n\r\nReturns a list of the best possible legal_moves for whoevers turn it is in UCI however, it is possible that one or more of the entries can be the string 'claim_draw' instead of a UCI which is to indicate the desire to claim a draw like FIFTY_MOVES or THREEFOLD_REPETITION\r\n\r\n\r\n\r\n get_whiteBlackPointsDifference(game: chess.Board) -> int\r\n\r\n \r\n\r\nReturns the point difference between white and black where Pawn: 1, Bishop: 3, Knight: 3, Rook: 5, Queen 9\r\n\r\n\r\n\r\n makeChessMove(uci: chess.Move | str) -> None\r\n\r\n \r\n\r\nNeeds to be at least pseudo_legal\r\n\r\n\r\n\r\n listAllPossibleMoves() -> List[Move]\r\n\r\n \r\n\r\nLists all possible legal_moves for whoevers turn it is for each piece\r\n\r\n\r\n\r\n listUCIPosPossibleMoves(uciPos: str) -> List[Move]\r\n\r\n \r\n\r\nLists all possible legal_moves for whoevers turn it is for the uciPos like 'a2', or 'b1'\r\n\r\nReturns an empty List if no possible moves\r\n\r\n\r\n\r\n reset() -> None \r\n\r\n \r\n\r\nResets board in chess.Board\r\n\r\n\r\n\r\n willMoveNeedPawnPromotion(uci: chess.Move | str) -> bool\r\n\r\n\r\n\r\nReturn True if move will result in a pawn promotion, False otherwise\r\n\r\n\r\n\r\n pieceToPieceType(result: chess.Piece | str) -> int\r\n\r\n \r\n\r\nReturn chess.PieceType as a int\r\n\r\n\r\n\r\n rowColToUCI(rowColFrom: list[int], rowColTo: list[int]) -> str\r\n\r\n \r\n\r\nAccepts two List[int] which is the row and col from and to locations \r\n\r\nReturns a str which is a uci representing the inputs\r\n\r\n\r\n\r\n uciToRowCol(uci: chess.Move | str) -> List[int], List[int]\r\n\r\n \r\n\r\nAccepts a str which is a uci\r\n\r\nReturns two List[int] which are the row and col from and to representing the inputs\r\n\r\n\r\n\r\n rowColToUCIPos(row: int col: int) -> str\r\n\r\n \r\n\r\nAccepts a row and col of a 2D list that is the chess board\r\n\r\nReturns a uciPos which is a single position like a2 or b1 representing the inputs\r\n\r\n\r\n\r\n uciToRowColPos(uciPos: str) -> int, int\r\n\r\n \r\n\r\nAccepts a uciPos which is a single position like a2 or b1 \r\n\r\nReturns a row and col of a 2D list that is the chess board representing the inputs\r\n\r\n\r\n\r\n uciToFlippedRowCol(uci: chess.Move | str) -> List[int], List[int]\r\n\r\n \r\n\r\nAccepts a uci\r\n\r\nReturns two List[int] which are the row and col from and to in a 2D list that is the chess board representing \r\n\r\nthe inputs but flipped so that white is on top and black is bottom\r\n\r\n\r\n\r\n flippedRowColToUCIPos(row: int, col: int) -> str\r\n\r\n \r\n\r\nAccepts a row and col position that has been flipped so that white is on top and black is on bottom\r\n\r\nReturns a uciPos which is a single position like a2 or b1 representing the inputs\r\n\r\n\r\n\r\n uciToFlippedRowColPos(uciPos: str) -> int, int\r\n\r\n \r\n\r\nAccepts a uciPos which is a single position like a2 or b1 \r\n\r\nReturns a row and col position that has been flipped so that white is on top and black is on bottom representing the inputs\r\n\r\n\r\n\r\n flipRowCol(rowColFrom: list[int], rowColTo: list[int]) -> List[int], List[int]\r\n\r\n \r\n\r\nAccepts two List[int] which is the row and col from and to locations \r\n\r\nReturns two List[int] which is the row and col from and to locations but flipped so that white is one top and black is on bottom\r\n\r\n\r\n\r\n flipRowColPos(row: int, col: int) -> int, int\r\n\r\n \r\n\r\nAccepts two int which is the row and col for a location\r\n\r\nReturns two int which is the row and col for a location but flipped so that white is one top and black is on bottom\r\n\r\n\r\n\r\n get_boardAs2DList() -> List[int][int]\r\n\r\n \r\n\r\nReturns a 2D list that represents the chess board with white on bottom and black on top for easy use \r\n\r\n\r\n\r\n get_boardAs2DListFlipped() -> List[int][int]\r\n\r\n \r\n\r\nReturns a 2D list that represents the chess board but flipped so white is on top and black is on bottom for easy use \r\n\r\n\r\n\r\n get_isWhiteTurn() -> bool\r\n\r\n \r\n\r\nReturns a bool where True is if it is white's turn and False if it is black's turn\r\n\r\n\r\n\r\n get_isStartOfGame() -> bool\r\n\r\n \r\n\r\nReturns a bool where True is if it is the start of the game and False if it isn't\r\n\r\n\r\n\r\n# Extra\r\n\r\n\r\n\r\nFor more information on how to use this project visit https://python-chess.readthedocs.io/en/latest/ where some of this project uses.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Basic chess features that includes an AI for decision making in Python",
"version": "2.0.8",
"split_keywords": [
"python",
"chess",
"ai",
"artificial intelligence",
"game",
"puzzle"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b81a26a45b3f48175f1ca3ca3d463b40e74907a797360d68da649abef1d507a",
"md5": "7c094eaebf2526925cb4705e3e6d747d",
"sha256": "b5dc2c6bbbc38805d1bf6a6de8527ca1a6fa8c16065c3a90ef0ca7fd8fad0515"
},
"downloads": -1,
"filename": "AI_Chess-2.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7c094eaebf2526925cb4705e3e6d747d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7083,
"upload_time": "2023-02-09T00:06:37",
"upload_time_iso_8601": "2023-02-09T00:06:37.463819Z",
"url": "https://files.pythonhosted.org/packages/0b/81/a26a45b3f48175f1ca3ca3d463b40e74907a797360d68da649abef1d507a/AI_Chess-2.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3e790b2ca6f73ccc77b86e9ac2468f3edf4f6f96396c295d0664e971fc69481d",
"md5": "2e6dc9974b19812c150c4d7b84143e28",
"sha256": "e1dfa89693d94656ab0dc75df461d2b8d778d2a43bd5176dbdc2fdda300e83b7"
},
"downloads": -1,
"filename": "AI-Chess-2.0.8.tar.gz",
"has_sig": false,
"md5_digest": "2e6dc9974b19812c150c4d7b84143e28",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7593,
"upload_time": "2023-02-09T00:06:39",
"upload_time_iso_8601": "2023-02-09T00:06:39.219462Z",
"url": "https://files.pythonhosted.org/packages/3e/79/0b2ca6f73ccc77b86e9ac2468f3edf4f6f96396c295d0664e971fc69481d/AI-Chess-2.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-09 00:06:39",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "ai-chess"
}