2P manual
This commit is contained in:
parent
fd5266d8de
commit
e6b017985e
|
@ -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
|
Loading…
Reference in New Issue