-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.py
64 lines (45 loc) · 1.09 KB
/
models.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from dataclasses import dataclass
from enum import Enum
from typing import List, Tuple
from bitarray import bitarray
class PathType(Enum):
EMPTY = " "
A = "A"
B = "B"
@dataclass(frozen=True, eq=True, order=True)
class GridPos:
__slots__ = ['x', 'y']
x: int
y: int
@dataclass(frozen=True, eq=True)
class Vec2:
x: int
y: int
@dataclass(frozen=True)
class Constraint:
"""
Contains the information of a constraint over our path.
Here it only contains an agent and a position indicating
that an agent can't be at some position.
"""
agent_idx: int
position: GridPos
class MoveType(Enum):
# Idx, length
NORMAL = (0, 1)
UNDERGROUND = (1, 4)
@dataclass(frozen=True)
class Move:
__slots__ = ['pos', 'blocking_path', 'mtype', 'weight']
pos: GridPos
blocking_path: bitarray
mtype: MoveType
weight: int
@dataclass(frozen=True)
class MoveOption:
__slots__ = ['offset', 'blocks', 'mtype', 'weight']
offset: Vec2
blocks: set[Vec2]
mtype: MoveType
weight: int
Solution = List[List[Tuple[GridPos, Move]]]