Added a section abot imports and dependencies and some initial design decisions for the game.

This commit is contained in:
Philipp Horstenkamp 2023-02-12 14:32:24 +01:00
parent edc5e78dc3
commit 218c2876cf
Signed by: Philipp
GPG Key ID: DD53EAC36AFB61B4

View File

@ -21,7 +21,9 @@
"## Content\n", "## Content\n",
"\n", "\n",
"* [The game rules](#the-game-rules) A short overview over the rules of the game.\n", "* [The game rules](#the-game-rules) A short overview over the rules of the game.\n",
"* [Some common Otello strategies](#some-common-otello-strategies) introduces some easy approaches to a classic Otello AI and defines some behavioral expectations." "* [Some common Otello strategies](#some-common-otello-strategies) introduces some easy approaches to a classic Otello AI and defines some behavioral expectations.\n",
"* [Initial design decisions](#initial-design-decisions) an explanation about some initial design decision and assumptions\n",
"* [Imports and dependencies](#imports-and-dependencies) explains what libraries where used"
], ],
"metadata": { "metadata": {
"collapsed": false "collapsed": false
@ -67,6 +69,23 @@
"collapsed": false "collapsed": false
} }
}, },
{
"cell_type": "markdown",
"source": [
"## Initial design decisions\n",
"\n",
"At the beginning of this project I made some design decisions.\n",
"The first onw was that I do not want to use a gym library because it limits the data formats accessible.\n",
"I choose to implement the hole game as entry in a stack in numpy arrays to be able to accommodate interfacing with a neural network easier and to use scipy pattern recognition tools to implement some game mechanics for a fast simulation cycle.\n",
"I chose to ignore player colors as far as I could instead a player perspective was used. Which allowed to change the perspective with a flipping of the sign. (multiplying with -1).\n",
"The array format should also allow for data multiplication or the breaking of strikt sequences by flipping the game along one the for axis, (horizontal, vertical, transpose along both diagonals).\n",
"\n",
"I wanted to implement different agents as classes that act on those game stacks."
],
"metadata": {
"collapsed": false
}
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
@ -80,12 +99,32 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Imports" "## Imports and dependencies\n",
"\n",
"The following direct dependencies where used for this project:\n",
"```toml\n",
"jupyter = \"^1.0.0\"\n",
"matplotlib = \"^3.6.3\"\n",
"numpy = \"^1.24.1\"\n",
"pytest = \"^7.2.1\"\n",
"python = \"3.10.*\"\n",
"scipy = \"^1.10.0\"\n",
"tqdm = \"^4.64.1\"\n",
"jupyterlab = \"^3.6.1\"\n",
"torchvision = \"^0.14.1\"\n",
"torchaudio = \"^0.13.1\"\n",
"```\n",
"* `Jupyter` and `jupyterlab` on pycharm was used as a IDE / Ipython was used to implement this code.\n",
"* `matplotlib` was used for visualisation and statistics.\n",
"* `numpy` was used for array support and mathematical functions\n",
"* `tqdm` was used for progress bars\n",
"* `scipy` contains fast pattern recognition tools for images. It was used to make an initial estimation about where possible turns should be.\n",
"* `torch` supplied the ANN functionalities."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 27,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -101,7 +140,9 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Constants" "## Constants\n",
"\n",
"Some general constants needed to be defined. Such as board game size and Player and Enemy representations. Also, directional offsets and the initial placement of blocks."
] ]
}, },
{ {
@ -112,7 +153,7 @@
"source": [ "source": [
"BOARD_SIZE: Final[int] = 8 # defines the board side length as 8\n", "BOARD_SIZE: Final[int] = 8 # defines the board side length as 8\n",
"PLAYER: Final[int] = 1 # defines the number symbolising the player as 1\n", "PLAYER: Final[int] = 1 # defines the number symbolising the player as 1\n",
"ENEMY: Final[int] = -1 # defines the number symbolising the enenemy as 1" "ENEMY: Final[int] = -1 # defines the number symbolising the enemy as -1"
] ]
}, },
{ {
@ -284,7 +325,7 @@
} }
], ],
"source": [ "source": [
"def plot_othello_board(board, ax=None):\n", "def plot_othello_board(board, ax=None) -> None:\n",
" \"\"\"Plots a single otello board.\n", " \"\"\"Plots a single otello board.\n",
"\n", "\n",
" If a matplot axis object is given the board will be plotted into that axis. If not an axis object will be generated.\n", " If a matplot axis object is given the board will be plotted into that axis. If not an axis object will be generated.\n",
@ -293,8 +334,6 @@
" board: The bord that should be plotted. Only a single games is allowed. A numpy array of the form 8x8 is expected.\n", " board: The bord that should be plotted. Only a single games is allowed. A numpy array of the form 8x8 is expected.\n",
" ax: If needed the\n", " ax: If needed the\n",
"\n", "\n",
" Returns:\n",
"\n",
" \"\"\"\n", " \"\"\"\n",
" plot_all = False\n", " plot_all = False\n",
" if ax is None:\n", " if ax is None:\n",