-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAgentInput.py
42 lines (32 loc) · 1.09 KB
/
AgentInput.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from typing import List
import pygame
class AgentInput:
movementDirTranslationList: List[pygame.Vector2] = [
pygame.Vector2(0, 0),
pygame.Vector2(-1, 0),
pygame.Vector2(1, 0),
pygame.Vector2(0, -1),
pygame.Vector2(0, 1),
pygame.Vector2(-1, -1),
pygame.Vector2(-1, 1),
pygame.Vector2(1, -1),
pygame.Vector2(1, 1),
]
def __init__(self):
self.movementDir: pygame.Vector2 = pygame.Vector2(0, 0)
self.kick: bool = False
self.kickPos: pygame.Vector2 = pygame.Vector2(0, 0)
self.reset()
def reset(self):
self.movementDir: pygame.Vector2 = pygame.Vector2(0, 0)
self.kick: bool = False
self.kickPos: pygame.Vector2 = pygame.Vector2(0, 0)
@staticmethod
def getInputNumber():
return len(AgentInput.movementDirTranslationList)
def setInputByIndex(self, stateId: int) -> None:
self.reset()
# Set movement direction
self.movementDir = self.movementDirTranslationList[
stateId % len(self.movementDirTranslationList)
]