# randomchessgame
Python library to come in handy when random chess game is needed.
# Installation.
$ pip install randomchessgame
# Basic usage.
from randomchessgame import random_chess_game
random_chess_game()
output will look like this:
1. Nf3 Nf6 2. g3 g6 3. Bg2 Bg7 4. c4 O-O 5. O-O d5 6. cxd5 Nxd5 7. Nc3 Nb6 8. d3 Nc6
# Usage with parameters.
You can specify the minimum length, exact length, first move etc. To do it, you have to specify it as parameter while calling a function. Below are listed all possible parameters with their brief explainations.
### length
Returns random game with exact length as specified by user while calling a function. If length is set to 10, the game will have 10 moves (e4 e5 count as two separate moves)
random_chess_game(length=10)
1. d4 c5 2. Nf3 cxd4 3. Bf4 Nf6 4. e3 Nd5 5. exd4 Nxf4
### min_length
Returns random game with minimum length as specified by user while calling a function. If min_length is set to 10, the game will have more moves than 10. May be 11 and 111 as well but never less or equal to min_length value.
random_chess_game(min_length=10)
1. d4 d5 2. Nf3 Nf6 3. c4 c6 4. Nc3 e6 5. Bg5 h6 6. Bxf6 Qxf6 7. e3 Nd7 8. Rc1 g6 9. Be2 Qe7
### startswith
Returns random game that has started with a specific move. There is no need to pass move characters (1. e4 e5 2. Nf3 Nf6 3. etc), only moves ('e4 e5 Nf3 Nf6).
random_chess_game(startswith='e4 e5 Nf3 Nf6')
1. e4 e5 2. Nf3 Nf6 3. Bc4 Nxe4 4. Nc3 Nxc3 5. dxc3 f6 6. Nh4 g6 7. f4 f5 8. Nxf5 d5
### endswith_mate
Returns random game that has ended with a mate.
random_chess_game(endswith_mate=True)
..... 75. a7 Rb8 76. Rxb8 Kg6 77. a8=Q Kg5 78. Qe4 h5 79. Rg3+ Kh6 80. Qg6#
### endswith_move
Returns random game that has ended with a specific move.
random_chess_game(endswith_move='Kf4')
..... 45. Kf4 e5+ 46. dxe5+ Ke6 47. Ke4 h5 48. gxh5 gxh5 49. c5 h4 50. Kf4
### cleargame
Returns random game without movechars.
random_chess_game(cleargame=True)
Nf3 h6 g3 d6 Bg2 Nd7 O-O g5 d4 Bg7 c4 Nf8 Nc3 Ng6 e4 g4 Ne1 e5
### adding your own file
There is a possibility to add your own file with games and make the func pick a game from it. To do so, pass path to the file while calling a function. Remember that the file should not contain pgn tags ('0-1' , '1-0', '1/2-1/2'), opening name, comments nor clock.
random_chess_game(file='path/to/file/with/games:)
### mixing params
You can mix parameters to get wanted result. It can look like this:
random_chess_game(endswith_mate=True, startswith='e4', min_length=25, cleargame=True)
e4 g6 d4 Bg7 Nc3 d6 h4 Nf6 f3 h5 Be3 c6 Qd2 b5 Bd3 Qc7 O-O-O a6 e5 Nd5
In case of file not containing accurate game, it will return:
No games found with the given criteria.
Raw data
{
"_id": null,
"home_page": "https://github.com/lot022/randomcg",
"name": "randomchessgame",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "chess",
"author": "lot022",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/e7/fc/454f38645ec50e974bff4937ec0db5daa27340db8c74a20c2dab01de2a81/randomchessgame-4.0.8.tar.gz",
"platform": null,
"description": "# randomchessgame\n\nPython library to come in handy when random chess game is needed.\n\n# Installation.\n\n $ pip install randomchessgame\n\n# Basic usage.\n\n from randomchessgame import random_chess_game\n random_chess_game()\n\noutput will look like this:\n\n 1. Nf3 Nf6 2. g3 g6 3. Bg2 Bg7 4. c4 O-O 5. O-O d5 6. cxd5 Nxd5 7. Nc3 Nb6 8. d3 Nc6\n\n# Usage with parameters.\n\nYou can specify the minimum length, exact length, first move etc. To do it, you have to specify it as parameter while calling a function. Below are listed all possible parameters with their brief explainations.\n\n### length \n\nReturns random game with exact length as specified by user while calling a function. If length is set to 10, the game will have 10 moves (e4 e5 count as two separate moves) \n\n random_chess_game(length=10)\n 1. d4 c5 2. Nf3 cxd4 3. Bf4 Nf6 4. e3 Nd5 5. exd4 Nxf4\n\n### min_length\n\nReturns random game with minimum length as specified by user while calling a function. If min_length is set to 10, the game will have more moves than 10. May be 11 and 111 as well but never less or equal to min_length value.\n\n random_chess_game(min_length=10)\n 1. d4 d5 2. Nf3 Nf6 3. c4 c6 4. Nc3 e6 5. Bg5 h6 6. Bxf6 Qxf6 7. e3 Nd7 8. Rc1 g6 9. Be2 Qe7\n\n### startswith\n\nReturns random game that has started with a specific move. There is no need to pass move characters (1. e4 e5 2. Nf3 Nf6 3. etc), only moves ('e4 e5 Nf3 Nf6).\n\n random_chess_game(startswith='e4 e5 Nf3 Nf6')\n 1. e4 e5 2. Nf3 Nf6 3. Bc4 Nxe4 4. Nc3 Nxc3 5. dxc3 f6 6. Nh4 g6 7. f4 f5 8. Nxf5 d5\n\n### endswith_mate\n\nReturns random game that has ended with a mate.\n\n random_chess_game(endswith_mate=True)\n ..... 75. a7 Rb8 76. Rxb8 Kg6 77. a8=Q Kg5 78. Qe4 h5 79. Rg3+ Kh6 80. Qg6#\n\n\n### endswith_move\n\nReturns random game that has ended with a specific move.\n\n random_chess_game(endswith_move='Kf4')\n ..... 45. Kf4 e5+ 46. dxe5+ Ke6 47. Ke4 h5 48. gxh5 gxh5 49. c5 h4 50. Kf4\n\n### cleargame\n\nReturns random game without movechars.\n\n random_chess_game(cleargame=True)\n Nf3 h6 g3 d6 Bg2 Nd7 O-O g5 d4 Bg7 c4 Nf8 Nc3 Ng6 e4 g4 Ne1 e5 \n\n### adding your own file\n\nThere is a possibility to add your own file with games and make the func pick a game from it. To do so, pass path to the file while calling a function. Remember that the file should not contain pgn tags ('0-1' , '1-0', '1/2-1/2'), opening name, comments nor clock.\n\n random_chess_game(file='path/to/file/with/games:)\n\n### mixing params\n\nYou can mix parameters to get wanted result. It can look like this:\n\n random_chess_game(endswith_mate=True, startswith='e4', min_length=25, cleargame=True)\n e4 g6 d4 Bg7 Nc3 d6 h4 Nf6 f3 h5 Be3 c6 Qd2 b5 Bd3 Qc7 O-O-O a6 e5 Nd5 \n \n\nIn case of file not containing accurate game, it will return:\n\n No games found with the given criteria.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python library to come in handy when random chess game is neeed.",
"version": "4.0.8",
"project_urls": {
"Homepage": "https://github.com/lot022/randomcg"
},
"split_keywords": [
"chess"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cdd3aaa8a51279523a2d91af39f5607f67786b7341ae649973678d412d5b11d8",
"md5": "473b339a950662d571e2fdbae74ac9dc",
"sha256": "c07c7e75aa5047694414a01048421250de9bd426e96976c875af872025320cac"
},
"downloads": -1,
"filename": "randomchessgame-4.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "473b339a950662d571e2fdbae74ac9dc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4392,
"upload_time": "2024-06-21T18:27:18",
"upload_time_iso_8601": "2024-06-21T18:27:18.747588Z",
"url": "https://files.pythonhosted.org/packages/cd/d3/aaa8a51279523a2d91af39f5607f67786b7341ae649973678d412d5b11d8/randomchessgame-4.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e7fc454f38645ec50e974bff4937ec0db5daa27340db8c74a20c2dab01de2a81",
"md5": "a55eaefa16e0f87cf184056d4e811103",
"sha256": "6370c5a2ae4eb2b040e40daf3c0967eb3c691e84980243b97aea81d6a33e3b1b"
},
"downloads": -1,
"filename": "randomchessgame-4.0.8.tar.gz",
"has_sig": false,
"md5_digest": "a55eaefa16e0f87cf184056d4e811103",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 1060252,
"upload_time": "2024-06-21T18:27:20",
"upload_time_iso_8601": "2024-06-21T18:27:20.197198Z",
"url": "https://files.pythonhosted.org/packages/e7/fc/454f38645ec50e974bff4937ec0db5daa27340db8c74a20c2dab01de2a81/randomchessgame-4.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-21 18:27:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lot022",
"github_project": "randomcg",
"github_not_found": true,
"lcname": "randomchessgame"
}