diff --git a/maps/001.json b/maps/001.json new file mode 100644 index 0000000..0928b3c --- /dev/null +++ b/maps/001.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 300, + "playground_size_w":400, + "playground_size_h":400, + "score_to_pass": 10, + "food_1": 5, + "food_2": 0, + "food_3": 0, + "garbage_1": 0, + "garbage_2": 0, + "garbage_3": 0 +} \ No newline at end of file diff --git a/maps/002.json b/maps/002.json new file mode 100644 index 0000000..235fef9 --- /dev/null +++ b/maps/002.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 350, + "playground_size_w":400, + "playground_size_h":400, + "score_to_pass": 20, + "food_1": 5, + "food_2": 1, + "food_3": 0, + "garbage_1": 0, + "garbage_2": 0, + "garbage_3": 0 +} \ No newline at end of file diff --git a/maps/003.json b/maps/003.json new file mode 100644 index 0000000..6c0c776 --- /dev/null +++ b/maps/003.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 500, + "playground_size_w":400, + "playground_size_h":400, + "score_to_pass": 30, + "food_1": 4, + "food_2": 2, + "food_3": 0, + "garbage_1": 3, + "garbage_2": 0, + "garbage_3": 0 +} \ No newline at end of file diff --git a/maps/004.json b/maps/004.json new file mode 100644 index 0000000..da6d22a --- /dev/null +++ b/maps/004.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 600, + "playground_size_w":400, + "playground_size_h":400, + "score_to_pass": 40, + "food_1": 8, + "food_2": 2, + "food_3": 0, + "garbage_1": 4, + "garbage_2": 0, + "garbage_3": 0 +} \ No newline at end of file diff --git a/maps/005.json b/maps/005.json new file mode 100644 index 0000000..1ca3f45 --- /dev/null +++ b/maps/005.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 800, + "playground_size_w":400, + "playground_size_h":400, + "score_to_pass": 50, + "food_1": 8, + "food_2": 4, + "food_3": 0, + "garbage_1": 3, + "garbage_2": 1, + "garbage_3": 0 +} \ No newline at end of file diff --git a/maps/006.json b/maps/006.json new file mode 100644 index 0000000..a19c80e --- /dev/null +++ b/maps/006.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 1000, + "playground_size_w":400, + "playground_size_h":400, + "score_to_pass": 60, + "food_1": 8, + "food_2": 4, + "food_3": 0, + "garbage_1": 5, + "garbage_2": 2, + "garbage_3": 0 +} \ No newline at end of file diff --git a/maps/007.json b/maps/007.json new file mode 100644 index 0000000..3892e8d --- /dev/null +++ b/maps/007.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 1200, + "playground_size_w":500, + "playground_size_h":500, + "score_to_pass": 70, + "food_1": 8, + "food_2": 4, + "food_3": 2, + "garbage_1": 4, + "garbage_2": 2, + "garbage_3": 0 +} \ No newline at end of file diff --git a/maps/008.json b/maps/008.json new file mode 100644 index 0000000..ae4feb4 --- /dev/null +++ b/maps/008.json @@ -0,0 +1,12 @@ +{ + "time_to_play": 1400, + "playground_size_w":500, + "playground_size_h":500, + "score_to_pass": 80, + "food_1": 6, + "food_2": 4, + "food_3": 2, + "garbage_1": 3, + "garbage_2": 2, + "garbage_3": 2 +} \ No newline at end of file diff --git a/maps/template.json b/maps/template.json new file mode 100644 index 0000000..0e3feb8 --- /dev/null +++ b/maps/template.json @@ -0,0 +1,13 @@ +{ + "time_to_play": 600, + "playground_size_w":650, + "playground_size_h":550, + "score_to_pass": 10, + "food_1": 3, + "food_2": 2, + "food_3": 5, + "garbage_1": 1, + "garbage_2": 1, + "garbage_3": 1 + +} \ No newline at end of file diff --git a/ml/ml_play_manual_1P.py b/ml/ml_play_manual_1P.py new file mode 100644 index 0000000..eac0627 --- /dev/null +++ b/ml/ml_play_manual_1P.py @@ -0,0 +1,41 @@ +import random +from pprint import pprint + +import orjson +import pygame + + +class MLPlay: + def __init__(self,ai_name,*args,**kwargs): + print("Initial ml script") + + def update(self, scene_info: dict, keyboard:list=[], *args, **kwargs): + """ + Generate the command according to the received scene information + """ + # pprint("AI received data from game :", orjson.dumps(scene_info)) + # pprint(scene_info) + actions = [] + + if pygame.K_UP in keyboard: + actions.append("UP") + elif pygame.K_DOWN in keyboard: + actions.append("DOWN") + + elif pygame.K_LEFT in keyboard: + actions.append("LEFT") + elif pygame.K_RIGHT in keyboard: + actions.append("RIGHT") + else: + actions.append("NONE") + + return actions + + + + def reset(self): + """ + Reset the status + """ + print("reset ml script") + pass diff --git a/src/env.py b/src/env.py index 47f8532..e7a4c2d 100644 --- a/src/env.py +++ b/src/env.py @@ -49,7 +49,7 @@ FOOD_LV3_SIZE = 50 # path of assets ASSET_PATH = path.join(path.dirname(__file__), "..", "asset") -LEVEL_PATH = path.join(path.dirname(__file__), "..", "levels") +LEVEL_PATH = path.join(path.dirname(__file__), "..", "maps") SOUND_PATH = path.join(path.dirname(__file__), "..", "asset", "sounds") MUSIC_PATH = path.join(path.dirname(__file__), "..", "asset", "music") diff --git a/src/game.py b/src/game.py index af4b4cb..11b759d 100644 --- a/src/game.py +++ b/src/game.py @@ -47,7 +47,6 @@ class SwimmingSquid(PaiaGame): self._used_file = "" self.foods = pygame.sprite.Group() self.sound_controller = SoundController(sound) - self._collision_mode = False self._overtime_count = 0 self._init_game() @@ -74,10 +73,6 @@ class SwimmingSquid(PaiaGame): game_params.playground_size_w, game_params.playground_size_h ) - if game_params.playground_size_h >= 500 and game_params.playground_size_w >= 500: - self._collision_mode = True - else: - self._collision_mode = False self._score_to_pass = game_params.score_to_pass self._frame_limit = game_params.time_to_play @@ -125,8 +120,7 @@ class SwimmingSquid(PaiaGame): self._check_foods_collision() # self._timer = round(time.time() - self._begin_time, 3) - if self._collision_mode: - self._check_squids_collision() + self._check_squids_collision() self.frame_count += 1 self._frame_count_down = self._frame_limit - self.frame_count @@ -189,7 +183,6 @@ class SwimmingSquid(PaiaGame): data_to_1p = { "frame": self.frame_count, - "collision_mode": self._collision_mode, "self_x": self.squid1.rect.centerx, "self_y": self.squid1.rect.centery, "self_w": self.squid1.rect.width, @@ -208,7 +201,6 @@ class SwimmingSquid(PaiaGame): data_to_2p = { "frame": self.frame_count, - "collision_mode": self._collision_mode, "self_x": self.squid2.rect.centerx, "self_y": self.squid2.rect.centery, "self_w": self.squid2.rect.width, @@ -242,9 +234,7 @@ class SwimmingSquid(PaiaGame): return status def reset(self): - if self.is_passed: - self._level += 1 self.sound_controller.play_cheer() else: self.sound_controller.play_fail()