{"id":15297511,"url":"https://github.com/lorddarkula/chess_py","last_synced_at":"2025-07-30T21:12:35.842Z","repository":{"id":62562002,"uuid":"56568158","full_name":"LordDarkula/chess_py","owner":"LordDarkula","description":"Chess library for simple chess engine creation","archived":false,"fork":false,"pushed_at":"2018-04-08T21:16:51.000Z","size":3194,"stargazers_count":13,"open_issues_count":7,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-14T21:44:51.338Z","etag":null,"topics":["chess-board","chess-engine","chess-game","game","player","python","python-2","python-library","python3"],"latest_commit_sha":null,"homepage":"http://lorddarkula.github.io/chess_py/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LordDarkula.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-19T05:47:38.000Z","updated_at":"2025-01-13T17:14:27.000Z","dependencies_parsed_at":"2022-11-03T15:17:23.391Z","dependency_job_id":null,"html_url":"https://github.com/LordDarkula/chess_py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LordDarkula/chess_py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LordDarkula%2Fchess_py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LordDarkula%2Fchess_py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LordDarkula%2Fchess_py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LordDarkula%2Fchess_py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LordDarkula","download_url":"https://codeload.github.com/LordDarkula/chess_py/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LordDarkula%2Fchess_py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263895758,"owners_count":23526717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess-board","chess-engine","chess-game","game","player","python","python-2","python-library","python3"],"created_at":"2024-09-30T19:18:02.625Z","updated_at":"2025-07-06T11:37:25.799Z","avatar_url":"https://github.com/LordDarkula.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chess_py\n\n![Board](http://i.stack.imgur.com/yQaOq.png)\n\n[![Build Status](https://travis-ci.org/LordDarkula/chess_py.svg?branch=master)](https://travis-ci.org/LordDarkula/chess_py)\n[![Code Climate](https://codeclimate.com/github/LordDarkula/chess_py/badges/gpa.svg)](https://codeclimate.com/github/LordDarkula/chess_py)\n[![PyPI version](https://badge.fury.io/py/chess_py.svg)](https://pypi.python.org/pypi/chess_py)\n[![Python27](https://img.shields.io/badge/python-2.7-blue.svg)](https://www.python.org/download/releases/2.7/)\n[![Python35](https://img.shields.io/badge/python-3.5-blue.svg)](https://www.python.org/downloads/release/python-350/)\n[![License](https://img.shields.io/cocoapods/l/EasyQL.svg?style=flat)](https://github.com/LordDarkula/chess_py/blob/master/LICENSE)\n[![Twitter](https://img.shields.io/badge/twitter-@LordDarkula-blue.svg?style=flat)](http://twitter.com/LordDarkula)\n\n## License\nchess_py is available under the MIT license. See the [LICENSE](https://github.com/LordDarkula/chess_py/blob/master/LICENSE) file for more info.\nCopyright © 2016 Aubhro Sengupta. All rights reserved.\n\n## Talk @Pygotham 2016\nI gave a talk at PyGotham 2016 on this library. Abstract can be found [here](https://2016.pygotham.org/talks/324/abstractions-and-building/).\n\n## Introduction\n\nChess_py is an open source chess library written in Python designed to aid in the creation of chess engines. Handles the chess so you can focus on the engine.\n\n## Installation\n\nTo use as a immediately start up a game between two human players in the console, navigate inside the root directory of the package and run main.py. \n\n```bash\npython main.py\n```\n\nTo install package  \n\n### ``pip`` (*Recommended*)\n```bash\npip install chess_py\n```\n\n### Or manually\n```bash\npython setup.py install\n```\n## Documentation\n\nView complete technical documentation [here](http://lorddarkula.github.io/chess_py/html/html/index.html).\n\n## Great! How do you use it? (*An Example*)\n\nChess_py has the capability of creating games between players, either human, or AI \n\n```python\nimport chess_py\nfrom chess_py import Game, Human, color\n\n\"\"\" Creates a Game with 2 humans. \nWhen run, this will open the console,\"\"\"\nnew_game = Game(Human(color.white), Human(color.black))\n\n\"\"\" After game is completed, outcome will be stored in result.\nThe integer result will be one of three values. \nwhite wins - 0, black wins - 1, draw - 0.5 \"\"\"\nresult = new_game.play()\n```\n\nTo build a chess engine on with chess_py, inherit Player and implement generate_move() \n\n```python\nimport chess_py\nfrom chess_py import Game, Human, color\n\n# Engine which plays the move with the highest immediate material advantage\nclass MyEngine(chess_py.Player):\n    def __init__(self, input_color):\n    \n      # Creates piece value scheme to specify value of each piece.\n      self.piece_values = chess_py.PieceValues.init_manual(PAWN_VALUE=1,\n                                                            KNIGHT_VALUE=3,\n                                                            BISHOP_VALUE=3,\n                                                            ROOK_VALUE=5,\n                                                            QUEEN_VALUE=9)\n      \n      # Super call to\n      super(chess_py.Player, self).__init__(input_color)\n    \n    def generate_move(self, position):\n      # position parameter is an object of type Board\n        \n      # Finds all possible moves I can play.\n      moves = position.all_possible_moves(self.color)\n      \n      # Initalizes best move and advantage after it has been played to dummy values.\n      best_move = None\n      best_move_advantage = -99\n      \n      # Loops through possible moves\n      for move in moves:\n        \"\"\" advantage_as_result(move, piece_values) finds numerical advantage\n        as specified by piece value scheme above. Returns negative values for\n        positions of disadvantage. Returns +/-99 for checkmate. \"\"\"\n        advantage = position.advantage_as_result(move, self.piece_values)\n        \n        # If this move is better than best move, it is the best move.\n        if advantage \u003e= best_move_advantage:\n            best_move = move\n            best_move_advantage = advantage\n      \n      return best_move\n\n# If file is run as script, a Game is set up between My_engine and Human and result is printed.\nif __name__ == \"__main__\":\n    new_game = Game(MyEngine(color.white), Human(color.black))\n    \n    # white wins - 0, black wins - 1, draw - 0.5 \n    print(\"Result: \", new_game.play())\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florddarkula%2Fchess_py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Florddarkula%2Fchess_py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florddarkula%2Fchess_py/lists"}