Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
hang man game work in progress
  • Loading branch information
sartre001 authored Mar 1, 2024
1 parent fd37edf commit d79d8df
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/mctslib/envs/hangman_test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import random"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"vacant_space = \"_____\"\n",
"word = hello\n",
"action ids are in the form of a tuple, so (index of vacant letter, index of letter of the alphabet to be tried)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class State:\n",
" def __init__(self, vacant_space, word, action_id = 0):\n",
" self.vacant_space = len(word)*\"_\"\n",
" self.word = word\n",
" self._evaluation = len(vacant_space/len(word)\n",
" self.action_id = action_id\n",
" \n",
" def find_children(self):\n",
" child_list = []\n",
" for i in vacant_space:\n",
" if i == \"_\":\n",
" child_list.append(list(range(27)))\n",
" \n",
" def apply_actions(self, action_id):\n",
" \n",
" \n",
" \n",
" def get_legal_actions(self):\n",
" return list(range(vacant_letters))\n",
" \n",
" def default_policy(self):\n",
" return random.choice(self.find_children())\n",
"\n",
" def evaluation(self):\n",
" return self._evaluation\n",
"\n",
" def is_terminal(self):\n",
" return False\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit d79d8df

Please sign in to comment.