def __init__(self, width=64, height=48, MAX_SCORE=11):

        actions = {
            "up": K_w,
            "down": K_s
        }

        PyGameWrapper.__init__(self, width, height, actions=actions)

        # the %'s come from original values, wanted to keep same ratio when you
        # increase the resolution.
        self.ball_radius = percent_round_int(height, 0.03)
        self.players_speed = 0.22 * height
        self.cpu_speed = 0.7 * height
        self.ball_speed = 0.75 * height
        self.paddle_width = percent_round_int(width, 0.023)
        self.paddle_height = percent_round_int(height, 0.15)
        self.paddle_dist_to_wall = percent_round_int(width, 0.0625)
        self.MAX_SCORE = MAX_SCORE

        self.dy = 0.0
        self.score_sum = 0.0  # need to deal with 11 on either side winning
        self.score_counts = {
            "agent": 0.0,
            "cpu": 0.0
        }
Exemplo n.º 2
0
    def __init__(self, width=64, height=64):

        actions = {"up": K_w, "left": K_a, "right": K_d, "down": K_s}

        PyGameWrapper.__init__(self, width, height, actions=actions)

        self.CREEP_BAD = {
            "radius_center": percent_round_int(width, 0.047),
            "radius_outer": percent_round_int(width, 0.265),
            "color_center": (110, 45, 45),
            "color_outer": (150, 95, 95),
            "speed": 0.05 * width
        }

        self.CREEP_GOOD = {
            "radius": percent_round_int(width, 0.047),
            "color": (40, 140, 40)
        }

        self.AGENT_COLOR = (60, 60, 140)
        self.AGENT_SPEED = 0.2 * width
        self.AGENT_RADIUS = percent_round_int(width, 0.047)
        self.AGENT_INIT_POS = (self.AGENT_RADIUS * 1.5,
                               self.AGENT_RADIUS * 1.5)

        self.BG_COLOR = (255, 255, 255)
        self.dx = 0
        self.dy = 0
        self.ticks = 0
    def __init__(self, width=48, height=48):
        actions = {
            "up": K_w
        }

        PyGameWrapper.__init__(self, width, height, actions=actions)

        self.is_climbing = False
        self.speed = 0.0004 * width
Exemplo n.º 4
0
    def __init__(self, width=WIDTH_GAME, height=HEIGHT, init_lives=10):
        actions = {
            "left": pygame.K_LEFT,
            "right": pygame.K_RIGHT,
            "shoot": pygame.K_SPACE
        }
        PyGameWrapper.__init__(self, width, height, actions=actions)
        self.init_lives = init_lives

        self.bullet_speed = 0.00003 * height

        self.player_speed = 0.05 * width
        self.dx = 0.0
        self.mob = None
        self.bullets = None
        self.powerups = None
Exemplo n.º 5
0
    def __init__(self, width=64, height=64, init_length=3):

        actions = {"up": K_w, "left": K_a, "right": K_d, "down": K_s}

        PyGameWrapper.__init__(self, width, height, actions=actions)

        self.speed = percent_round_int(width, 0.45)

        self.player_width = percent_round_int(width, 0.05)
        self.food_width = percent_round_int(width, 0.09)
        self.player_color = (100, 255, 100)
        self.food_color = (255, 100, 100)

        self.INIT_POS = (width / 2, height / 2)
        self.init_length = init_length

        self.BG_COLOR = (25, 25, 25)
    def __init__(self, width=48, height=48, num_preys=1, num_hunters=2):

        multi_actions = {
            0: {
                "up": K_w,
                "left": K_a,
                "right": K_d,
                "down": K_s
            },
            1: {
                "up": K_UP,
                "left": K_LEFT,
                "right": K_RIGHT,
                "down": K_DOWN
            }
        }

        # multi_actions = {
        #     K_w: {"up": 0},
        #     K_a: {"left": 0},
        #     K_d: {"right": 0},
        #     K_s: {"down": 0},
        #     K_UP: {"up": 1},
        #     K_DOWN: {"down": 1},
        #     K_RIGHT: {"right": 1},
        #     K_LEFT: {"left": 1},
        # }

        PyGameWrapper.__init__(self, width, height, actions=multi_actions)
        self.BG_COLOR = (255, 255, 255)
        self.PREY_NUM = num_preys
        self.HUNTER_NUM = num_hunters

        self.HUNTER_COLOR = (60, 60, 140)
        self.HUNTER_SPEED = 0.25 * width
        self.HUNTER_RADIUS = percent_round_int(width, 0.07)

        self.PREY_COLOR = (40, 140, 40)
        self.PREY_SPEED = 0.25 * width
        self.PREY_RADIUS = percent_round_int(width, 0.047)

        self.hunters = pygame.sprite.Group()
        self.hunters_list = []
        self.preys = pygame.sprite.Group()
        self.agents = []
Exemplo n.º 7
0
    def __init__(self,
                 init_pos=(1, 1),
                 resolution=1,
                 move_speed=20,
                 turn_speed=13,
                 map_size=10,
                 height=48,
                 width=48):

        assert map_size > 5, "map_size must be gte 5"

        # do not change
        init_dir = (1.0, 0.0)
        init_plane = (0.0, 0.66)

        block_types = {
            0: {
                "pass_through": True,
                "color": None
            },
            1: {
                "pass_through": False,
                "color": (255, 255, 255)
            },
            2: {
                "pass_through": False,
                "color": (255, 100, 100)
            }
        }
        actions = {"forward": K_w, "left": K_a, "right": K_d, "backward": K_s}

        PyGameWrapper.__init__(self, width, height, actions=actions)

        RayCastPlayer.__init__(self, None, init_pos, init_dir, width, height,
                               resolution, move_speed, turn_speed, init_plane,
                               actions, block_types)

        self.init_pos = np.array([init_pos], dtype=np.float32)
        self.init_dir = np.array([init_dir], dtype=np.float32)
        self.init_plane = np.array([init_plane], dtype=np.float32)

        self.obj_loc = None
        self.map_size = map_size
    def __init__(self,
                 width=48,
                 height=48,
                 num_creeps=3):

        actions = {
            "up": K_w,
            "left": K_a,
            "right": K_d,
            "down": K_s
        }

        PyGameWrapper.__init__(self, width, height, actions=actions)
        self.BG_COLOR = (255, 255, 255)
        self.N_CREEPS = num_creeps
        self.CREEP_TYPES = ["GOOD", "BAD"]
        self.CREEP_COLORS = [(40, 140, 40), (150, 95, 95)]
        radius = percent_round_int(width, 0.047)
        self.CREEP_RADII = [radius, radius]
        self.CREEP_REWARD = [
            self.rewards["positive"],
            self.rewards["negative"]]
        self.CREEP_SPEED = 0.25 * width
        self.AGENT_COLOR = (60, 60, 140)
        self.AGENT_SPEED = 0.25 * width
        self.AGENT_RADIUS = radius
        self.AGENT_INIT_POS = (self.width / 2, self.height / 2)

        self.creep_counts = {
            "GOOD": 0,
            "BAD": 0
        }

        self.dx = 0
        self.dy = 0
        self.player = None
        self.creeps = None