Skip to content

제 3장 코드에서 width,height 혼동 문제. #40

@hccho2

Description

@hccho2

1-grid-word ---> 1-policy-iteration 에서

코드 전제적으로 width, height 순서가 맞지 않습니다.
코드에서는 widht=5, height=5로 되어 있어, 작동하지만,
width=5, height=6이면, 작동하지 않습니다.

예들 들어,

self.value_table = [[0.0] * env.width for _ in range(env.height)]  # height x width

--->

self.value_table = [[0.0] * env.height for _ in range(env.width)]  # width x height

코드 전체를 좀 손봐야 할 것 같습니다.

graphic상 에서는 height, width 순으로 되어 있는 것과 반대로, value, reward를 width, height순으로 되어 있는데. 이때문에 혼동이 일어난 것 같습니다.

그리고,

POSSIBLE_ACTIONS = [0, 1, 2, 3]  # 좌, 우, 상, 하

def draw_one_arrow(self, col, row, policy):
    if col == 2 and row == 2:
        return

    if policy[0] > 0:  # up
        origin_x, origin_y = 50 + (UNIT * row), 10 + (UNIT * col)
        self.arrows.append(self.canvas.create_image(origin_x, origin_y,image=self.up))
    if policy[1] > 0:  # down
        origin_x, origin_y = 50 + (UNIT * row), 90 + (UNIT * col)
        self.arrows.append(self.canvas.create_image(origin_x, origin_y,image=self.down))
    if policy[2] > 0:  # left
        origin_x, origin_y = 10 + (UNIT * row), 50 + (UNIT * col)
        self.arrows.append(self.canvas.create_image(origin_x, origin_y,image=self.left))
    if policy[3] > 0:  # right
        origin_x, origin_y = 90 + (UNIT * row), 50 + (UNIT * col)
        self.arrows.append(self.canvas.create_image(origin_x, origin_y,image=self.right))

policy에서의 방향과 draw_one_arrow()에서의 sync가 맞지 않습니다.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions