random_num

This commit is contained in:
Andy Walner
2023-06-26 07:18:21 -07:00
parent b76c37c57a
commit 255112a2eb
2 changed files with 6 additions and 6 deletions

View File

@@ -695,9 +695,9 @@
"source": [
"def epsilon_greedy_policy(Qtable, state, epsilon):\n",
" # Randomly generate a number between 0 and 1\n",
" random_float = random.uniform(0,1)\n",
" # if random_float > greater than epsilon --> exploitation\n",
" if random_float > epsilon:\n",
" random_num = random.uniform(0,1)\n",
" # if random_num > greater than epsilon --> exploitation\n",
" if random_num > epsilon:\n",
" # Take the action with the highest value given a state\n",
" # np.argmax can be useful here\n",
" action = greedy_policy(Qtable, state)\n",

View File

@@ -388,9 +388,9 @@ def epsilon_greedy_policy(Qtable, state, epsilon):
```python
def epsilon_greedy_policy(Qtable, state, epsilon):
# Randomly generate a number between 0 and 1
random_int = random.uniform(0, 1)
# if random_int > greater than epsilon --> exploitation
if random_int > epsilon:
random_num = random.uniform(0, 1)
# if random_num > greater than epsilon --> exploitation
if random_num > epsilon:
# Take the action with the highest value given a state
# np.argmax can be useful here
action = greedy_policy(Qtable, state)