File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -343,7 +343,7 @@ def __add__(self, heading):
343343 elif self .direction == self .L :
344344 return {
345345 self .R : Direction (self .U ),
346- self .L : Direction (self .L ),
346+ self .L : Direction (self .D ),
347347 }.get (heading , None )
348348 elif self .direction == self .U :
349349 return {
Original file line number Diff line number Diff line change 1+ from agents import Direction
2+
3+ def test_move_forward ():
4+ d = Direction ("up" )
5+ l1 = d .move_forward ((0 ,0 ))
6+ assert l1 == (0 ,- 1 )
7+ d = Direction (Direction .R )
8+ l1 = d .move_forward ((0 ,0 ))
9+ assert l1 == (1 ,0 )
10+ d = Direction (Direction .D )
11+ l1 = d .move_forward ((0 ,0 ))
12+ assert l1 == (0 ,1 )
13+ d = Direction ("left" )
14+ l1 = d .move_forward ((0 ,0 ))
15+ assert l1 == (- 1 ,0 )
16+ l2 = d .move_forward ((1 ,0 ))
17+ assert l2 == (0 ,0 )
18+
19+ def test_add ():
20+ d = Direction (Direction .U )
21+ l1 = d + "right"
22+ l2 = d + "left"
23+ assert l1 .direction == Direction .R
24+ assert l2 .direction == Direction .L
25+ d = Direction ("right" )
26+ l1 = d .__add__ (Direction .L )
27+ l2 = d .__add__ (Direction .R )
28+ assert l1 .direction == "up"
29+ assert l2 .direction == "down"
30+ d = Direction ("down" )
31+ l1 = d .__add__ ("right" )
32+ l2 = d .__add__ ("left" )
33+ assert l1 .direction == Direction .L
34+ assert l2 .direction == Direction .R
35+ d = Direction (Direction .L )
36+ l1 = d + Direction .R
37+ l2 = d + Direction .L
38+ assert l1 .direction == Direction .U
39+ assert l2 .direction == Direction .D #fixed
40+
You can’t perform that action at this time.
0 commit comments