예제 #1
0
 def test_angle_shot(self):
     # Shot above the center:
     self.their_attacker.vector = Vector(self.pitch.width - 50, self.our_goal.y, pi/4, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker), self.our_goal.y + 50)
     # Shot below the center:
     self.their_attacker.vector = Vector(self.pitch.width - 50, self.our_goal.y, (7*pi)/4, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker), self.our_goal.y - 50)
예제 #2
0
 def test_straight_shot(self):
     # Shot to the center:
     self.their_attacker.vector = Vector(400, self.our_goal.y, 0, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker), self.our_goal.y)
     # Shot to the bottom:
     goal_top = self.our_goal.y - (self.our_goal.width/2.0)
     self.their_attacker.vector = Vector(400, goal_top, 0, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker), goal_top)
예제 #3
0
 def test_straight_corrected_shot(self):
     # Shot above the top:
     goal_top = self.our_goal.y + (self.our_goal.width/2.0)
     self.their_attacker.vector = Vector(200, goal_top + 20, 0, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker), goal_top)
     # Shot below the bottom:
     goal_bottom = self.our_goal.y - (self.our_goal.width/2.0)
     self.their_attacker.vector = Vector(200, goal_bottom - 20, 0, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker), goal_bottom)
예제 #4
0
 def test_bounce_shot(self):
     # Shot bounced of the top:
     self.their_attacker.vector = Vector(self.pitch.width - self.pitch.height, self.pitch.height/2.0, pi/4, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker, bounce=True), self.pitch.height/2.0)
     # Shot bounced of the bottom:
     self.their_attacker.vector = Vector(self.pitch.width - self.pitch.height, self.pitch.height/2.0, (7*pi)/4, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker, bounce=True), self.pitch.height/2.0)
     # Shot bounced of the top that needs to be corrected:
     goal_top = self.our_goal.y + (self.our_goal.width/2.0)
     self.their_attacker.vector = Vector(self.pitch.width - (self.pitch.height/2.0), self.pitch.height/2.0, (3*pi)/16, 0)
     assert_almost_equal(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker, bounce=True), goal_top)
예제 #5
0
 def test_no_intersection(self):
     self.their_attacker.vector = Vector(self.pitch.height, self.pitch.height/2.0, pi/4, 0)
     self.assertEqual(predict_y_intersection(self.planner._world, self.our_goal.x, self.their_attacker), None)