Skip to content

improvement in agents.py #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Next Next commit
adding tests for agent directions
  • Loading branch information
KaiRawal committed Mar 7, 2017
commit ae0d9d16aa94b9252612af25c674dab88f3ee4ec
40 changes: 40 additions & 0 deletions tests/test_agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from agents import Direction

def test_move_forward():
d = Direction("up")
l1 = d.move_forward((0,0))
assert l1 == (0,-1)
d = Direction(Direction.R)
l1 = d.move_forward((0,0))
assert l1 == (1,0)
d = Direction(Direction.D)
l1 = d.move_forward((0,0))
assert l1 == (0,1)
d = Direction("left")
l1 = d.move_forward((0,0))
assert l1 == (-1,0)
l2 = d.move_forward((1,0))
assert l2 == (0,0)

def test_add():
d = Direction(Direction.U)
l1 = d + "right"
l2 = d + "left"
assert l1.direction == Direction.R
assert l2.direction == Direction.L
d = Direction("right")
l1 = d.__add__(Direction.L)
l2 = d.__add__(Direction.R)
assert l1.direction == "up"
assert l2.direction == "down"
d = Direction("down")
l1 = d.__add__("right")
l2 = d.__add__("left")
assert l1.direction == Direction.L
assert l2.direction == Direction.R
d = Direction(Direction.L)
l1 = d + Direction.R
l2 = d + Direction.L
assert l1.direction == Direction.U
#assert l2.direction == Direction.D currently gives an error - need to fix bug in agents.py

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy