-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactions.py
More file actions
28 lines (24 loc) · 720 Bytes
/
actions.py
File metadata and controls
28 lines (24 loc) · 720 Bytes
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
from typing import Tuple, List
class Actions:
UP = 'up'
DOWN = 'down'
LEFT = 'left'
RIGHT = 'right'
STAY = 'stay'
actions = (UP, DOWN, LEFT, RIGHT, STAY)
@staticmethod
def value(action: str) -> Tuple[int, int]:
if action == Actions.UP:
return -1, 0
if action == Actions.DOWN:
return 1, 0
if action == Actions.RIGHT:
return 0, 1
if action == Actions.LEFT:
return 0, -1
if action == Actions.STAY:
return 0, 0
raise Exception('Invalid action')
@staticmethod
def values(actions: List) -> List[Tuple[int, int]]:
return [Actions.value(action) for action in actions]