def positiveMove(self, currentBoard): # setUp: self.pMove.clear() # Your code: mL = [] if (self.white): m1 = self.point + Point(0, 1) mL.append(m1) if (self.point.y > 4): for i in range(-1, 2, 2): mL.append(self.point + Point(i, 0)) for m in mL: if ((not self.isTeammatePoint(m, currentBoard)) and m.checkOnBoard()): # add tP in Positive Move: self.pMove.append(m) # _____________________________________ elif (not self.white): m1 = self.point + Point(0, -1) mL.append(m1) if (self.point.y < 5): for i in range(-1, 2, 2): mL.append(self.point + Point(i, 0)) for m in mL: if ((not self.isTeammatePoint(m, currentBoard)) and m.checkOnBoard()): # add tP in Positive Move: self.pMove.append(m)
def test_point_distance(): a = Point() b = Point(10, 10) distance = a.distance(b) assert distance == 14.142135623730951
def test_point_distance(self): p1 = Point(2, 5) p2 = Point(2, 5) p3 = Point(10, 9) self.assertEqual(p1.distance(p2), 0.0) self.assertEqual(p1.distance(p3), round(8.94427190999916, 2))
def test_point_constructor(): point = Point() assert point.x == 0.0 assert point.y == 0.0 point = Point(1, 3) assert point.x == 1.0 assert point.y == 3.0
def test_point_operators(): a = Point() b = Point() c = Point(2, 10) assert a == b assert not a != b assert b != c assert not b == c
def createTot(board): for i in range(2): for j in range(5): if (i == 0): tot = Tot(Point(j * 2, 3), 1) elif (i == 1): tot = Tot(Point(j * 2, 6), 0) board.chesses.append(tot) board.activeChesses.append(tot)
def test_point_operators(): p1 = Point() p2 = Point() p3 = Point(1, 10) assert p1 == p2 assert not p1 == p3 assert not p1 != p2 assert p1 != p3
def test_comparison_operators(): p1 = Point() p2 = Point() p3 = Point(2.0, 4.0) assert p1 == p2 assert not p1 == p3 assert p1 != p3 assert not p1 != p2
def createTot(): for i in range(2): for j in range(5): if (i == 0): tot = Tot(Point(j * 2, 3), 1) elif (i == 1): tot = Tot(Point(j * 2, 6), 0) chess.add(tot) for c in chesses: if type(c) == TempPoint: if (c.point == tot.point): c.deactivate()
def test_point_cmp_methods(self): p1 = Point(2, 5) p2 = Point(2, 5) p3 = Point(10, 9) self.assertEqual(p1, p2) self.assertNotEqual(p1, p3) self.assertTrue(p1 == p2) self.assertFalse(p1 == p3) self.assertTrue(p1 != p3) self.assertFalse(p1 != p2)
def test_point_setters(): point = Point() point.x = 42 point.y = 42 assert point.x == 42.0 assert point.y == 42.0
def __init__(self, point, white): if (white == 1): Chess.__init__(self, point, "K", white) self.primitiveMove = [] for i in range(3, 6, 1): for j in range(0, 3, 1): self.primitiveMove.append(Point(i, j)) elif (white == 0): Chess.__init__(self, point, "k", white) self.primitiveMove = [] for i in range(3, 6, 1): for j in range(7, 10, 1): self.primitiveMove.append(Point(i, j)) self.value = 10000
def __init__(self, point, white): if (white == 1): Chess.__init__(self, point, "E", white) self.primitiveMove = [] for i in range(0, 9, 1): for j in range(0, 5, 1): self.primitiveMove.append(Point(i, j)) elif (white == 0): Chess.__init__(self, point, "e", white) self.primitiveMove = [] for i in range(0, 9, 1): for j in range(5, 10, 1): self.primitiveMove.append(Point(i, j)) self.value = 120
def test_point_setters(self): point = Point() self._test_point(point, 0, 0) point.x = 42 point.y = 20 self._test_point(point, 42, 20)
def test_point_setters_exception(value, exception_type): point = Point() with pytest.raises(exception_type): point.x = value with pytest.raises(exception_type): point.y = value
def test_point_representation(): point = Point() repr_string = repr(point) point_string = str(point) assert repr_string == '(0.0, 0.0)' assert point_string == '(0.0, 0.0)'
def test_operators_exception(): class Test: pass p = Point() with pytest.raises(TypeError): assert p == Test()
def createKing(): for i in range(2): king = King(Point(4, 0 + i * 9), 1 - i) chess.add(king) for c in chesses: if type(c) == TempPoint: if (c.point == king.point): c.deactivate()
def createSi(): for i in range(2): for j in range(2): si = Si(Point(3 + j * 2, i * 9), 1 - i) chess.add(si) for c in chesses: if type(c) == TempPoint: if (c.point == si.point): c.deactivate()
def normalize(points): from point.point import Point from point.coordinates.coordinates import lat_lng return [ Point( lat_lng(lat=(point.coord.lat / (90 * 2)) + 0.5, lng=(point.coord.lng / (180 * 2)) + 0.5, r=2), point.timestamp, point.extra) for point in points ]
def test_point_not_implemented(): class Test: pass test = Test() p1 = Point() assert p1.__eq__(test) == NotImplemented assert p1.__ne__(test) == NotImplemented
def positiveMove(self, currentBoard): # setUp: self.pMove.clear() # Your code: for i in range(self.point.x + 1, 9, 1): tPoint = Point(i, self.point.y) if (not chess.isChessPoint(tPoint, currentBoard)): self.pMove.append(tPoint) else: if (self.isTeammatePoint(tPoint, currentBoard)): break else: self.pMove.append(tPoint) break for i in range(self.point.x - 1, -1, -1): tPoint = Point(i, self.point.y) if (not chess.isChessPoint(tPoint, currentBoard)): self.pMove.append(tPoint) else: if (self.isTeammatePoint(tPoint, currentBoard)): break else: self.pMove.append(tPoint) break for i in range(self.point.y + 1, 10, 1): tPoint = Point(self.point.x, i) if (not chess.isChessPoint(tPoint, currentBoard)): self.pMove.append(tPoint) else: if (self.isTeammatePoint(tPoint, currentBoard)): break else: self.pMove.append(tPoint) break for i in range(self.point.y - 1, -1, -1): tPoint = Point(self.point.x, i) if (not chess.isChessPoint(tPoint, currentBoard)): self.pMove.append(tPoint) else: if (self.isTeammatePoint(tPoint, currentBoard)): break else: self.pMove.append(tPoint) break
def test_closest(self): result = closest(Test.points[0], Test.points[1:]) expected = \ DistanceTuple( point=Point( coord=lat_lng(lat=-56, lng=111, r=6371), timestamp=1, extra={'status': 'HAPPY'}), distance=566605.5984774233) self.assertEqual(result, expected)
def test_furthest(self): result = furthest(Test.points[0], Test.points[1:]) expected = \ DistanceTuple( point=Point( coord=lat_lng(lat=-76, lng=-134, r=6371), timestamp=2, extra={'status': 'HAPPY'}), distance=711820.7738464935) self.assertEqual(result, expected)
def __init__(self, capacity: float = 60, consumption: float = 0.6, location: Point = Point(0, 0), model: str = 'Mercedes') -> None: self._fuel_amount = 0 self._fuel_capacity = float(capacity) self._fuel_consumption = float(consumption) self._model = str(model) self._location = location
def test_point_properties(): point = Point() assert point.x == 0.0 assert point.y == 0.0 point.x = 10.0 point.y = 10.0 assert point.x == 10.0 assert point.y == 10.0
def test_setters(): point = Point() assert point.x == POINT_DEFAULT assert point.y == POINT_DEFAULT point.x = POINT_NEW_VALUE point.y = POINT_NEW_VALUE assert point.x == POINT_NEW_VALUE assert point.y == POINT_NEW_VALUE
def __init__(self, point, white): if (white == 1): Chess.__init__(self, point, "X", white) elif (white == 0): Chess.__init__(self, point, "x", white) self.primitiveMove = [] for i in range(9): for j in range(10): self.primitiveMove.append(Point(i, j)) self.value = 600
def test_point_setters(): p = Point() assert p.x == 0.0 assert p.y == 0.0 p.x = 10 p.y = 22 assert p.x == 10.0 assert p.y == 22.0
def positiveMove(self, currentBoard): #setUp: self.pMove.clear() # Your code: for m in self.primitiveMove: if ((abs(m.x - self.point.x) == 1 and abs(m.y - self.point.y) == 2) or (abs(m.x - self.point.x) == 2 and abs(m.y - self.point.y) == 1)): if (not self.isTeammatePoint(m, currentBoard)): if (abs(m.x - self.point.x) == 1): if (not (chess.isChessPoint( Point( self.point.x, self.point.y + (m.y - self.point.y) / abs(m.y - self.point.y)), currentBoard))): self.pMove.append(m) elif (abs(m.x - self.point.x) == 2): if (not (chess.isChessPoint( Point( self.point.x + (m.x - self.point.x) / abs(m.x - self.point.x), self.point.y), currentBoard))): self.pMove.append(m)