Пример #1
0
    def test_team_vectors_multiple_per_team(self):
        fpp = FootPrintPackage()

        fp_1_a = FootPrint(Token.ATTACKING, W, self.team_1)
        fp_1_b = FootPrint(Token.DANGER, S, self.team_1)

        fp_2_a = FootPrint(Token.ATTACKING, S, self.team_2)
        fp_2_b = FootPrint(Token.OBJECTIVE, N, self.team_2)
        fp_2_c = FootPrint(Token.DEAD, N, self.team_2)

        fpp.push(fp_1_a)
        fpp.push(fp_1_b)
        fpp.push(fp_2_a)
        fpp.push(fp_2_b)
        fpp.push(fp_2_c)

        answer = fpp.team_vectors()
        team_1_answer = answer[self.team_1]
        team_2_answer = answer[self.team_2]

        self.assertEqual(team_1_answer.danger, Vector(-1, -1))
        self.assertEqual(team_1_answer.opportunity, Vector(-2, 0))

        self.assertEqual(team_2_answer.danger, Vector(0, 1))
        self.assertEqual(team_2_answer.opportunity, Vector(0, -1))
Пример #2
0
 def test_FootPrintPackage_push(self):
     fpp = FootPrintPackage()
     fp_1 = FootPrint(Token.DANGER, W, self.team_2)
     fp_2 = FootPrint(Token.NEUTRAL, N, self.team_3)
     fpp.push(fp_1)
     self.assertEqual(fpp.footprints, [fp_1])
     fpp.push(fp_2)
     self.assertEqual(fpp.footprints, [fp_2, fp_1])
Пример #3
0
 def test_add_footprint(self):
     team = 'team'
     footprint = FootPrint(Token.ATTACKING, Direction.N, team)
     tile = Tile()
     self.assertEqual(tile.footprint_vectors(), {})
     tile.add_footprint(footprint)
     self.assertEqual(tile.footprint_vectors(),
                      {'team': footprint.vectorize()})
Пример #4
0
 def test_FootPrintPackage_push_greater_than_max_size_two(self):
     fpp = FootPrintPackage(2)
     fp_1 = FootPrint(Token.DANGER, W, self.team_2)
     fp_2 = FootPrint(Token.NEUTRAL, N, self.team_3)
     fp_3 = FootPrint(Token.OBJECTIVE, S, self.team_1)
     fpp.push(fp_1)
     fpp.push(fp_2)
     self.assertEqual(fpp.footprints, [fp_2, fp_1])
     fpp.push(fp_3)
     self.assertEqual(fpp.footprints, [fp_3, fp_2])
Пример #5
0
    def test_team_vectors_one_per_team(self):

        fp_1 = FootPrint(Token.DANGER, W, self.team_1)
        for token, direction in zip(Token, cycle(Direction)):
            fpp = FootPrintPackage()
            fp_2 = FootPrint(token, direction, self.team_2)
            fpp.push(fp_1)
            fpp.push(fp_2)
            answer = fpp.team_vectors()
            self.assertEqual(
                answer, {
                    self.team_1:
                    DangerOpportunity(danger=Vector(-1, 0),
                                      opportunity=Vector(0, 0)),
                    self.team_2:
                    fp_2.vectorize(),
                })
Пример #6
0
 def test_add_footprint_multiple_footprints_single_team(self):
     team = 'team'
     footprint = FootPrint(Token.ATTACKING, Direction.N, team)
     footprint2 = FootPrint(Token.DANGER, Direction.E, team)
     tile = Tile()
     self.assertEqual(tile.footprint_vectors(), {})
     tile.add_footprint(footprint)
     tile.add_footprint(footprint2)
     self.assertEqual(
         tile.footprint_vectors(),
         {'team': footprint.vectorize().add(footprint2.vectorize())})
Пример #7
0
    def test_footprint_vectorize(self):
        footprint = FootPrint(Token.ATTACKING, E, self.team_1)
        answer = footprint.vectorize()
        self.assertEqual(answer.danger, Vector.from_dir_and_mag(E, 1))
        self.assertEqual(answer.opportunity, Vector.from_dir_and_mag(E, 2))

        footprint = FootPrint(Token.ATTACKING, N, self.team_1)
        answer = footprint.vectorize()
        self.assertEqual(answer.danger, Vector.from_dir_and_mag(N, 1))
        self.assertEqual(answer.opportunity, Vector.from_dir_and_mag(N, 2))

        footprint = FootPrint(Token.ATTACKING, S, self.team_1)
        answer = footprint.vectorize()
        self.assertEqual(answer.danger, Vector.from_dir_and_mag(S, 1))
        self.assertEqual(answer.opportunity, Vector.from_dir_and_mag(S, 2))

        footprint = FootPrint(Token.ATTACKING, W, self.team_1)
        answer = footprint.vectorize()
        self.assertEqual(answer.danger, Vector.from_dir_and_mag(W, 1))
        self.assertEqual(answer.opportunity, Vector.from_dir_and_mag(W, 2))
Пример #8
0
 def test_footprint_init(self):
     footprint_1 = FootPrint(Token.DEAD, N, self.team_1)
     self.assertEqual(footprint_1.token, Token.DEAD)
     self.assertEqual(footprint_1.direction, N)
     self.assertEqual(footprint_1.team, self.team_1)
Пример #9
0
    def test_add_footprint_multiple_footprints_multiple_teams(self):
        team_1 = 'team_1'
        footprint = FootPrint(Token.ATTACKING, Direction.N, team_1)
        footprint2 = FootPrint(Token.DANGER, Direction.E, team_1)

        team_2 = 'team_2'
        footprint3 = FootPrint(Token.DEAD, Direction.W, team_2)
        footprint4 = FootPrint(Token.NEUTRAL, Direction.S, team_2)

        tile = Tile()
        self.assertEqual(tile.footprint_vectors(), {})
        tile.add_footprint(footprint)
        tile.add_footprint(footprint4)
        tile.add_footprint(footprint3)
        tile.add_footprint(footprint2)

        expected = {
            team_1: footprint.vectorize().add(footprint2.vectorize()),
            team_2: footprint3.vectorize().add(footprint4.vectorize())
        }

        self.assertEqual(tile.footprint_vectors(), expected)