# plAIer
A Python library that uses a reinforcement learning AI to play board games such as Chess, Tic Tac Toe, and Reversi.
You can also find the project on [PyPI][]
[PyPI]: https://pypi.org/project/plAIer/
## Example of use
```python
# The current game state :
gameState = """
X | O |
---+---+---
O | O | X
---+---+---
X | | O
"""
# Import the library :
import plAIer
# Create database if not exists :
plAIer.createDatabase("database_filename.json", "database_name", "description", ["outcomes", "list"])
# Initialize the AI :
outcomesRating = {"O won": 1, "tie": 0, "X won": -1} # The definition of outcomes allows us to determine what the goals of the AI are.
AI = plAIer.Game("database_filename.json", outcomesRating)
# Find the best move in the current game position :
bestMove = AI.findBestMove([
{"move" : "[0, 2]",
"stateAfterMove": "\n X | O | O\n---+---+---\n O | O | X\n---+---+---\n X | | O\n"},
{"move" : "[2, 1]",
"stateAfterMove": "\n X | O | \n---+---+---\n O | O | X\n---+---+---\n X | O | O\n"}
])
print(eval(bestMove)) # Output : [2, 1]
```
### Database format
Databases are JSON files which follow this format :
```json
{
"name": "name of the game",
"description": "additional informations",
"outcomes": ["list", "of", "outcomes"],
"data": {"gameState1": {"outcome1": 1234, "outcome2": 2345, "outcomeN": 4567},
"gameState2": {"outcome1": 5678, "outcome2": 6789, "outcomeN": 7890},
"gameStateN": {"outcome1": 8901, "outcome2": 9011, "outcomeN": 0}
}
}
```
## How to get it
Write on your terminal (bash or Windows cmd/powershell) the following command :
```bash
pip install plAIer
```
## Contribute
Don't hesitate to contribute with pull requests :
1. Fork the repository
2. Do your commits
3. Add your pull request on the repository with a description of what your pull request does
Raw data
{
"_id": null,
"home_page": "https://github.com/L-Martin7/plAIer",
"name": "plAIer",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "AI, artificial intelligence, play, game, reinforcement AI, player, board games",
"author": "L-Martin7",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/b6/c3/9c54e3c1dbe4eac1e98f0567ed5a7ab1b744f01850afe0dc1f3a3ffc9635/plaier-1.0.1.tar.gz",
"platform": "Linux",
"description": "# plAIer\n\nA Python library that uses a reinforcement learning AI to play board games such as Chess, Tic Tac Toe, and Reversi.\n\nYou can also find the project on [PyPI][]\n\n[PyPI]: https://pypi.org/project/plAIer/\n\n## Example of use\n```python\n# The current game state :\ngameState = \"\"\"\n X | O | \n---+---+---\n O | O | X\n---+---+---\n X | | O\n\"\"\"\n\n# Import the library :\nimport plAIer\n\n# Create database if not exists :\nplAIer.createDatabase(\"database_filename.json\", \"database_name\", \"description\", [\"outcomes\", \"list\"])\n\n# Initialize the AI :\noutcomesRating = {\"O won\": 1, \"tie\": 0, \"X won\": -1} # The definition of outcomes allows us to determine what the goals of the AI are.\nAI = plAIer.Game(\"database_filename.json\", outcomesRating)\n\n# Find the best move in the current game position :\nbestMove = AI.findBestMove([\n {\"move\" : \"[0, 2]\",\n \"stateAfterMove\": \"\\n X | O | O\\n---+---+---\\n O | O | X\\n---+---+---\\n X | | O\\n\"},\n {\"move\" : \"[2, 1]\",\n \"stateAfterMove\": \"\\n X | O | \\n---+---+---\\n O | O | X\\n---+---+---\\n X | O | O\\n\"}\n])\n\nprint(eval(bestMove)) # Output : [2, 1]\n```\n\n### Database format\nDatabases are JSON files which follow this format :\n```json\n{\n \"name\": \"name of the game\",\n \"description\": \"additional informations\",\n \"outcomes\": [\"list\", \"of\", \"outcomes\"],\n \"data\": {\"gameState1\": {\"outcome1\": 1234, \"outcome2\": 2345, \"outcomeN\": 4567},\n \"gameState2\": {\"outcome1\": 5678, \"outcome2\": 6789, \"outcomeN\": 7890},\n \"gameStateN\": {\"outcome1\": 8901, \"outcome2\": 9011, \"outcomeN\": 0}\n }\n}\n```\n\n## How to get it\nWrite on your terminal (bash or Windows cmd/powershell) the following command :\n```bash\npip install plAIer\n```\n\n## Contribute\nDon't hesitate to contribute with pull requests :\n1. Fork the repository\n2. Do your commits\n3. Add your pull request on the repository with a description of what your pull request does\n",
"bugtrack_url": null,
"license": "BSD 3-Clause \"New\" or \"Revised\" License",
"summary": "A Python library that uses a reinforcement learning AI to play board games such as Chess, Tic Tac Toe, and Reversi.",
"version": "1.0.1",
"project_urls": {
"Download": "https://pypi.python.org/pypi/plAIer",
"Homepage": "https://github.com/L-Martin7/plAIer",
"Issues": "https://github.com/L-Martin7/plAIer/issues",
"Source": "https://github.com/L-Martin7/plAIer"
},
"split_keywords": [
"ai",
" artificial intelligence",
" play",
" game",
" reinforcement ai",
" player",
" board games"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f863c2663bd7fd4288599a2ffae042e60e638f997c4858a3d1614dbd6976c7d8",
"md5": "602fa8ec8610d8736606c673f9d5bb41",
"sha256": "d30eeeb7e15e6516aba1180f5b24b9dada4326583542bc791ee43d0b94004ff1"
},
"downloads": -1,
"filename": "plAIer-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "602fa8ec8610d8736606c673f9d5bb41",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4561,
"upload_time": "2024-12-20T18:06:32",
"upload_time_iso_8601": "2024-12-20T18:06:32.312757Z",
"url": "https://files.pythonhosted.org/packages/f8/63/c2663bd7fd4288599a2ffae042e60e638f997c4858a3d1614dbd6976c7d8/plAIer-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b6c39c54e3c1dbe4eac1e98f0567ed5a7ab1b744f01850afe0dc1f3a3ffc9635",
"md5": "a5ace7bb6d1060d767160489179e1a5d",
"sha256": "e956714b9fd77b8f1503ae9e816730fd530eaca86ba780ad4ac4197bff83c974"
},
"downloads": -1,
"filename": "plaier-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "a5ace7bb6d1060d767160489179e1a5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4252,
"upload_time": "2024-12-20T18:06:35",
"upload_time_iso_8601": "2024-12-20T18:06:35.948475Z",
"url": "https://files.pythonhosted.org/packages/b6/c3/9c54e3c1dbe4eac1e98f0567ed5a7ab1b744f01850afe0dc1f3a3ffc9635/plaier-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-20 18:06:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "L-Martin7",
"github_project": "plAIer",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "plaier"
}