Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions agents4e.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,10 +875,10 @@ def __init__(self, agent_program, width=6, height=6):
def init_world(self, program):
"""Spawn items in the world based on probabilities from the book"""

"WALLS"
# WALLS
self.add_walls()

"PITS"
# PITS
for x in range(self.x_start, self.x_end):
for y in range(self.y_start, self.y_end):
if random.random() < self.pit_probability:
Expand All @@ -888,18 +888,18 @@ def init_world(self, program):
self.add_thing(Breeze(), (x + 1, y), True)
self.add_thing(Breeze(), (x, y + 1), True)

"WUMPUS"
# WUMPUS
w_x, w_y = self.random_location_inbounds(exclude=(1, 1))
self.add_thing(Wumpus(lambda x: ""), (w_x, w_y), True)
self.add_thing(Stench(), (w_x - 1, w_y), True)
self.add_thing(Stench(), (w_x + 1, w_y), True)
self.add_thing(Stench(), (w_x, w_y - 1), True)
self.add_thing(Stench(), (w_x, w_y + 1), True)

"GOLD"
# GOLD
self.add_thing(Gold(), self.random_location_inbounds(exclude=(1, 1)), True)

"AGENT"
# AGENT
self.add_thing(Explorer(program), (1, 1), True)

def get_world(self, show_walls=True):
Expand Down