@@ -76,48 +76,6 @@ def step(self) -> None:
7676 def advance (self ) -> None :
7777 pass
7878
79- def move_forward_or_backward (self , amount , sign ):
80- """Does the calculation to find the agent's next move and is used within the forward and backward functions"""
81- new_x = float (self .pos [0 ]) + sign * math .cos (self .heading * math .pi / 180 ) * amount
82- new_y = float (self .pos [1 ]) + sign * math .sin (self .heading * math .pi / - 180 ) * amount
83- next_pos = (new_x , new_y )
84- try :
85- self .model .space .move_agent (self , next_pos )
86- except :
87- print ("agent.py (forward_backwards): could not move agent within self.model.space" )
88-
89- def move_forward (self , amount ):
90- """Moves the agent forward by the amount given"""
91- self .move_forward_or_backward (amount , 1 )
92-
93- def move_backward (self , amount ):
94- """Moves the agent backwards from where its facing by the given amount"""
95- self .move_forward_or_backward (amount , - 1 )
96-
97- def turn_right (self , degree ):
98- """Turns the agent right by the given degree"""
99- self .heading = (self .heading - degree ) % 360
100-
101- def turn_left (self , degree ):
102- """Turns the agent left by the given degree"""
103- self .heading = (self .heading + degree ) % 360
104-
105- def setxy (self , x , y ):
106- """Sets the current position to the specified x,y parameters"""
107- self .pos = (x , y )
108-
109- def set_pos (self , apos ):
110- """Sets the current position to the specified pos parameter"""
111- self .pos = apos
112-
113- def distancexy (self , x , y ):
114- """Gives you the distance of the agent and the given coordinate"""
115- return math .dist (self .pos , (x , y ))
116-
117- def distance (self , another_agent ):
118- """Gives you the distance between the agent and another agent"""
119- return self .distancexy (another_agent .pos [0 ], another_agent .pos [1 ])
120-
12179 def die (self ):
12280 """Removes the agent from the schedule and the grid """
12381 try :
@@ -129,28 +87,6 @@ def die(self):
12987 except :
13088 print ("agent.py (die): could not remove agent from self.model.space" )
13189
132- def towardsxy (self , x , y ):
133- """Calculates angle between a given coordinate and horizon as if the current position is the origin"""
134- dx = x - float (self .pos [0 ])
135- dy = float (self .pos [1 ]) - y
136- if dx == 0 :
137- return 90 if dy > 0 else 270
138- else :
139- return math .degrees (math .atan2 (dy , dx ))
140-
141- def towards (self , another_agent ):
142- """Calculates angle between an agent and horizon as if the current position is the origin"""
143- return self .towardsxy (* another_agent .pos )
144-
145- def facexy (self , x , y ):
146- """Makes agent face a given coordinate"""
147- self .heading = self .towardsxy (x , y )
148-
149- def face (self , another_agent ):
150- """Makes agent face another agent"""
151- x , y = another_agent .pos
152- self .facexy (x , y )
153-
15490 @property
15591 def random (self ) -> Random :
15692 return self .model .random
0 commit comments