Skip to content

Commit

Permalink
add state labels
Browse files Browse the repository at this point in the history
  • Loading branch information
yasutak committed Jul 5, 2020
1 parent 1b1723e commit d1d9cd5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions chapter03/grid_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,20 @@ def draw_image(image):

# Add cells
for (i, j), val in np.ndenumerate(image):

# add state labels
if [i, j] == A_POS:
val = str(val) + " (A)"
if [i, j] == A_PRIME_POS:
val = str(val) + " (A')"
if [i, j] == B_POS:
val = str(val) + " (B)"
if [i, j] == B_PRIME_POS:
val = str(val) + " (B')"

tb.add_cell(i, j, width, height, text=val,
loc='center', facecolor='white')


# Row and column labels...
for i in range(len(image)):
Expand Down Expand Up @@ -88,6 +100,17 @@ def draw_policy(optimal_values):
val=''
for ba in best_actions:
val+=ACTIONS_FIGS[ba]

# add state labels
if [i, j] == A_POS:
val = str(val) + " (A)"
if [i, j] == A_PRIME_POS:
val = str(val) + " (A')"
if [i, j] == B_POS:
val = str(val) + " (B)"
if [i, j] == B_PRIME_POS:
val = str(val) + " (B')"

tb.add_cell(i, j, width, height, text=val,
loc='center', facecolor='white')

Expand Down

0 comments on commit d1d9cd5

Please sign in to comment.