Ejemplo n.º 1
0
    def __init__(self, coords, mirror=False):
        super().__init__(coords, mirror)
        self.turret_slots = [[4, 12], [3, 10]]
        self.air_support_9_11 = [3, 10]

        # wall length
        WALL_LENGTH = 3
        # 3: should leave 3 10 open for divebomb

        self.wall_vip = [[0 + i, 13 - i] for i in range(WALL_LENGTH)]
        self.optional_wall = [3, 13]

        if self.mirror:
            self.turret_slots = gamelib.mirror(self.turret_slots)
            self.wall_vip = gamelib.mirror(self.wall_vip)
            self.optional_wall = gamelib.mirror(self.optional_wall)[0]
            self.air_support_9_11 = gamelib.mirror(self.air_support_9_11)[0]
Ejemplo n.º 2
0
 def init_wall(self):
     coords = [[],[]]
     for i in range(4):
         for j in range(2):
             to_add = [GREATWALL[0][0]+i, GREATWALL[0][1]-j]
             coords[0].append(to_add)
             coords[1]+= (gamelib.mirror(to_add))
     
     return coords
Ejemplo n.º 3
0
    def __init__(self, coords, mirror=False):
        super().__init__(coords, mirror)

        # slots that should and can have turrets
        self.turret_slots = [
            [9 + i, 11 - i] for i in range(5)
        ]  # whenever building new turret append to this. Order of uprading turret is decided in this order too
        if mirror:
            self.turret_slots = gamelib.mirror(self.turret_slots)
Ejemplo n.º 4
0
    def init_funnel(self):
        coords = [[],[]]
        for i in range(5):
            for j in range(5-i):
                to_add = [FUNNEL[0][0]-i ,FUNNEL[0][1]-j]
                coords[0].append(to_add)
                coords[1] += (gamelib.mirror(to_add))

        return coords
Ejemplo n.º 5
0
    def init_entrance(self):
        coords = [[],[]]

        for i in range(5):
            to_add = [ENTRANCE[0][0]+i,ENTRANCE[0][1]-i]
            to_add2 = [to_add[0],to_add[1]+1]
            coords[0] += [to_add,to_add2]
            coords[1] += gamelib.mirror([to_add,to_add2])

        return coords
Ejemplo n.º 6
0
    def aa_middle(self,game_state,MP_points):
        startLeft = int(MP_points/2)
        startRight = MP_points - startLeft

        if 2 * 2 <= startLeft:
            game_state.attempt_spawn(INTERCEPTOR,LEFTHOME, 2)
            startLeft-=2
        if 2*2 <= startRight:
            game_state.attempt_spawn(INTERCEPTOR,RIGHTHOME,2)
            startRight-=2
        
        game_state.attempt_spawn(INTERCEPTOR, [7,6], startLeft)
        game_state.attempt_spawn(INTERCEPTOR, gamelib.mirror([7,6]), startRight)
Ejemplo n.º 7
0
    def init_farmland(self):
        coords = []
        cur = FARM[0]
        width = abs(FARM[2][0] - FARM[0][0]) +1
        height = abs(FARM[1][1] - FARM[0][1]) + 1

        for y in range(height):
            for x in range(width):
                to_add = [ cur[0]-(x), cur[1]+(y)+x ]
                coords.append(to_add)
                #mirror returns a list of coords
                coords += (gamelib.mirror(to_add))
                
        return coords
Ejemplo n.º 8
0
    def reinforce(self, game_state, SP_points):
        # upgrade turret -> upgrade wall -> turret + wall
        random.shuffle(self.turret_slots)

        for i in self.turret_slots:
            if not self.final_form and i in [HOLE, gamelib.mirror(HOLE)[0]]:
                continue
            empty_wall = True
            wall_upgradable = False
            wall = game_state.contains_stationary_unit([i[0], i[1] + 1])
            if wall:
                empty_wall = False
                wall_upgradable = not wall.upgraded

            empty_turret = True
            turret_upgradable = False
            turret = game_state.contains_stationary_unit(i)

            if turret:
                empty_turret = False
                turret_upgradable = not turret.upgraded

            if turret_upgradable and SP_points >= 4:
                game_state.attempt_upgrade(i)

            SP_points = game_state.get_allowance()

            if wall_upgradable and SP_points >= 2:
                game_state.attempt_upgrade([i[0], i[1] + 1])

            SP_points = game_state.get_allowance()

            if empty_turret and empty_wall and SP_points >= 3:
                game_state.attempt_spawn(WALL, [i[0], i[1] + 1])
                game_state.attempt_spawn(TURRET, i)

            SP_points = game_state.get_allowance()
Ejemplo n.º 9
0
    def starting_setup(self, game_state, turn ):


        ## Defense
        if turn == 0:
            wall_coords = [[0,13], [1,12], [2,11], [3,10] ]

            # for the other hole
            wall_coords = wall_coords[:3]
            
            wall_coords += gamelib.mirror(wall_coords)

            turret_coords = [[5,12]]
            turret_coords += gamelib.mirror(turret_coords)

            interceptor_coords = [[7,6]]
            
            
            interceptor_coords += gamelib.mirror(interceptor_coords)
            # should always succeed
            game_state.attempt_spawn(WALL,wall_coords)
            game_state.attempt_spawn(TURRET,turret_coords)
            game_state.attempt_upgrade(turret_coords)

            game_state.attempt_spawn(INTERCEPTOR, interceptor_coords,2)
            game_state.attempt_spawn(INTERCEPTOR, interceptor_coords[0], 1 )

            game_state.attempt_spawn(WALL, [turret_coords[0][0],turret_coords[0][1]+1])

            # for the turret in hole scenrario
            game_state.attempt_spawn(WALL, gamelib.mirror([turret_coords[0][0],turret_coords[0][1]+1]))
            
            self.add_factory(game_state, 9)

            # to update information
            # i need a function for left and right, that basically just updates its units 
            
            
            self.left.end_turn(game_state)
            self.right.end_turn(game_state)
        
        elif turn == 1:

            SP_points = game_state.get_resource(0,0)
            
            game_state.attempt_spawn(WALL,gamelib.mirror([5,13]))

            # possible sp after other wall 4- 9
            if SP_points == 4: 
                pass # wait for next sp
            elif SP_points == 9:
                self.add_factory(game_state, 9)
            else:
                # make sure i have 4 sp left. 
                can_spend = SP_points - 4
                # 5,6,7,8 - 4 = 1,2,3,4
                if can_spend == 1:
                    # add a wall
                    game_state.attempt_spawn(WALL,(13,8) )
                elif can_spend == 2:
                    # add 2 walls
                    game_state.attempt_spawn(WALL,(13,8) )
                    game_state.attempt_spawn(WALL , gamelib.mirror([13,8]) )

                else:
                    # add wall with turret
                    game_state.attempt_spawn(WALL,(13,8) )
                    game_state.attempt_spawn(TURRET,(13,7) )

                
            
            # interceptors. Have 6 MP_points now
            game_state.attempt_spawn(INTERCEPTOR, [7,6], 3)
            game_state.attempt_spawn(INTERCEPTOR, gamelib.mirror([7,6]), 3)

            # to update information
            self.left.end_turn(game_state)
            self.right.end_turn(game_state)

        elif turn == 2:
            SP_points = game_state.get_resource(0,0)

            if SP_points == 9:
                self.add_factory(game_state,9)
                game_state.attempt_spawn(INTERCEPTOR, [7,6], 3)
                game_state.attempt_spawn(INTERCEPTOR, gamelib.mirror([7,6]), 3)

                self.left.end_turn(game_state)
                self.right.end_turn(game_state)
            else:
                # less than
                self.tower_defense_loop(game_state)