Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
Update main code
Browse files Browse the repository at this point in the history
  • Loading branch information
killian-mahe committed Oct 2, 2021
1 parent 8b015a6 commit f60a9ca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .idea/agent-aspirateur.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions vacuum-agent/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,24 @@ def __init__(self, agent, environment):
def run(self):
stored_state = self.environment.map()
stored_sequence = None
action_id = 0
percept_timer = 1

while self.agent.alive:

percept_timer -= 1
current_state = self.environment.map()

if percept_timer <= 0 and current_state[1::] != stored_state[1::] and len(current_state) > 1:
stored_state = current_state
stored_sequence = self.agent(self.environment.percept())
action_id = 0
if stored_sequence and action_id < len(stored_sequence):
self.environment.execute_action(stored_sequence[action_id], True)
action_id += 1

if stored_sequence:
self.environment.execute_action(stored_sequence.pop(0), True)

if percept_timer <= 0:
percept_timer = 5
sleep(0.05)

sleep(0.2)


def convert_position(position: Position):
Expand Down
1 change: 0 additions & 1 deletion vacuum-agent/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ def __init__(self):
Thing.__init__(self)
SimpleProblemSolvingAgentProgram.__init__(self)
self.alive = True
self.performance = 0

def update_state(self, state: State, percept) -> State:
"""
Expand Down

0 comments on commit f60a9ca

Please sign in to comment.