update all to 2.0.0
This commit is contained in:
0
ai_clients/__init__.py
Normal file
0
ai_clients/__init__.py
Normal file
BIN
ai_clients/__pycache__/client_template.cpython-39.pyc
Normal file
BIN
ai_clients/__pycache__/client_template.cpython-39.pyc
Normal file
Binary file not shown.
24
ai_clients/client_template.py
Normal file
24
ai_clients/client_template.py
Normal file
@ -0,0 +1,24 @@
|
||||
import random
|
||||
|
||||
|
||||
class MLPlay:
|
||||
def __init__(self, ai_name:str,*args, **kwargs):
|
||||
print(f"Initial {__file__} script with ai_name:{ai_name}")
|
||||
|
||||
|
||||
def update(self, scene_info: dict, *args, **kwargs):
|
||||
"""
|
||||
Generate the command according to the received scene information
|
||||
"""
|
||||
# print("AI received data from game :", json.dumps(scene_info))
|
||||
# print(scene_info)
|
||||
actions = ["UP", "DOWN", "LEFT", "RIGHT"]
|
||||
|
||||
return random.sample(actions, 1)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Reset the status
|
||||
"""
|
||||
print("reset ml script")
|
||||
pass
|
26
ai_clients/client_with_error_in_update.py
Normal file
26
ai_clients/client_with_error_in_update.py
Normal file
@ -0,0 +1,26 @@
|
||||
import random
|
||||
|
||||
|
||||
class MLPlay:
|
||||
def __init__(self, *args, **kwargs):
|
||||
print("Initial ml script")
|
||||
self.count=0
|
||||
|
||||
def update(self, scene_info: dict, *args, **kwargs):
|
||||
"""
|
||||
Generate the command according to the received scene information
|
||||
"""
|
||||
# print("AI received data from game :", json.dumps(scene_info))
|
||||
# print(scene_info)
|
||||
actions = ["UP", "DOWN", "LEFT", "RIGHT"]
|
||||
self.count+=1
|
||||
if self.count >100:
|
||||
a = actions[100]
|
||||
return random.sample(actions, 1)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Reset the status
|
||||
"""
|
||||
print("reset ml script")
|
||||
pass
|
22
ai_clients/client_with_syntax_error.py
Normal file
22
ai_clients/client_with_syntax_error.py
Normal file
@ -0,0 +1,22 @@
|
||||
import random
|
||||
|
||||
class MLPlay:
|
||||
def __init__(self, *args, **kwargs)
|
||||
print("Initial ml script")
|
||||
|
||||
def update(self, scene_info: dict, *args, **kwargs):
|
||||
"""
|
||||
Generate the command according to the received scene information
|
||||
"""
|
||||
# print("AI received data from game :", json.dumps(scene_info))
|
||||
# print(scene_info)
|
||||
actions = ["UP", "DOWN", "LEFT", "RIGHT"]
|
||||
|
||||
return random.sample(actions, 1)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Reset the status
|
||||
"""
|
||||
print("reset ml script")
|
||||
pass
|
24
ai_clients/client_with_unvalid_import.py
Normal file
24
ai_clients/client_with_unvalid_import.py
Normal file
@ -0,0 +1,24 @@
|
||||
import random
|
||||
import aaa
|
||||
|
||||
|
||||
class MLPlay:
|
||||
def __init__(self, *args, **kwargs):
|
||||
print("Initial ml script")
|
||||
|
||||
def update(self, scene_info: dict, *args, **kwargs):
|
||||
"""
|
||||
Generate the command according to the received scene information
|
||||
"""
|
||||
# print("AI received data from game :", json.dumps(scene_info))
|
||||
# print(scene_info)
|
||||
actions = ["UP", "DOWN", "LEFT", "RIGHT"]
|
||||
|
||||
return random.sample(actions, 1)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Reset the status
|
||||
"""
|
||||
print("reset ml script")
|
||||
pass
|
36
ai_clients/manual.py
Normal file
36
ai_clients/manual.py
Normal file
@ -0,0 +1,36 @@
|
||||
import pygame
|
||||
|
||||
|
||||
class MLPlay:
|
||||
def __init__(self, ai_name: str, *args, **kwargs):
|
||||
self.ai_name = ai_name
|
||||
print(f"Initial {__file__} script with ai_name:{ai_name}")
|
||||
|
||||
def update(self, scene_info: dict, keyboard: list = [], *args, **kwargs):
|
||||
"""
|
||||
Generate the command according to the received scene information
|
||||
"""
|
||||
# print("AI received data from game :", json.dumps(scene_info))
|
||||
# print(scene_info)
|
||||
actions = []
|
||||
|
||||
if pygame.K_w in keyboard or pygame.K_UP in keyboard:
|
||||
actions.append("UP")
|
||||
elif pygame.K_s in keyboard or pygame.K_DOWN in keyboard:
|
||||
actions.append("DOWN")
|
||||
|
||||
elif pygame.K_a in keyboard or pygame.K_LEFT in keyboard:
|
||||
actions.append("LEFT")
|
||||
elif pygame.K_d in keyboard or 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
|
Reference in New Issue
Block a user