-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hang man game work in progress
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |