Skip to content

Commit b01d2f6

Browse files
First commit : Agent moves randomly
1 parent 708f63b commit b01d2f6

File tree

8 files changed

+284
-3
lines changed

8 files changed

+284
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 0
6+
}

projects/smartcab/smartcab/Test.ipynb

Lines changed: 270 additions & 0 deletions
Large diffs are not rendered by default.

projects/smartcab/smartcab/agent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def __init__(self, env):
1111
self.color = 'red' # override color
1212
self.planner = RoutePlanner(self.env, self) # simple route planner to get next_waypoint
1313
# TODO: Initialize any additional variables here
14+
self.correct_actions = ["forward","left","right",None]
1415

1516
def reset(self, destination=None):
1617
self.planner.route_to(destination)
@@ -25,7 +26,11 @@ def update(self, t):
2526
# TODO: Update state
2627

2728
# TODO: Select action according to your policy
28-
action = None
29+
30+
#1st Q. Implement a basic agent that chooses action randomly
31+
# action = random.choice(self.correct_actions)
32+
# what if the next_waypoint was chosen as the action?
33+
action = self.next_waypoint
2934

3035
# Execute action and get reward
3136
reward = self.env.act(self, action)
@@ -41,7 +46,7 @@ def run():
4146
# Set up environment and agent
4247
e = Environment() # create environment (also adds some dummy traffic)
4348
a = e.create_agent(LearningAgent) # create agent
44-
e.set_primary_agent(a, enforce_deadline=True) # specify agent to track
49+
e.set_primary_agent(a, enforce_deadline=False) # specify agent to track
4550
# NOTE: You can set enforce_deadline=False while debugging to allow longer trials
4651

4752
# Now simulate it
5.12 KB
Binary file not shown.
10.6 KB
Binary file not shown.
1.69 KB
Binary file not shown.

projects/smartcab/smartcab/simulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, env, size=None, update_delay=1.0, display=True, live_plot=Fal
5151
self.agent_sprite_size = (32, 32)
5252
self.agent_circle_radius = 10 # radius of circle, when using simple representation
5353
for agent in self.env.agent_states:
54-
agent._sprite = self.pygame.transform.smoothscale(self.pygame.image.load(os.path.join("images", "car-{}.png".format(agent.color))), self.agent_sprite_size)
54+
agent._sprite = self.pygame.transform.smoothscale(self.pygame.image.load(os.path.join("../images", "car-{}.png".format(agent.color))), self.agent_sprite_size)
5555
agent._sprite_size = (agent._sprite.get_width(), agent._sprite.get_height())
5656

5757
self.font = self.pygame.font.Font(None, 28)
7.05 KB
Binary file not shown.

0 commit comments

Comments
 (0)