2P manual

This commit is contained in:
yanshaoting 2024-03-12 15:01:54 +08:00
parent fd5266d8de
commit e6b017985e
1 changed files with 42 additions and 0 deletions

42
ml/ml_play_manual_2P.py Normal file
View File

@ -0,0 +1,42 @@
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_w in keyboard:
actions.append("UP")
elif pygame.K_s in keyboard:
actions.append("DOWN")
elif pygame.K_a in keyboard:
actions.append("LEFT")
elif pygame.K_d in keyboard:
actions.append("RIGHT")
else:
actions.append("NONE")
return actions
def reset(self):
"""
Reset the status
"""
print("reset ml script")
pass