-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockClass.py
More file actions
47 lines (38 loc) · 1.03 KB
/
blockClass.py
File metadata and controls
47 lines (38 loc) · 1.03 KB
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
allBlocks = {}
class Block:
def __init__(self, w, h, x, y, name):
self.height, self.width, self.x, self.y, self.name = h, w, x, y, name
allBlocks[self.name] = self
if self.height > self.width:
self.vertical = 1
else:
self.vertical = 0
class OptimalBlock:
def __init__(self, length, vertical, x, y, name):
self.length, self.vertical, self.x, self.y, self.name = length, vertical, x, y, name
allBlocks[self.name] = self
self.pos = [self.x, self.y]
def __repr__(self):
return '[ ' + str(self.length) + \
', ' + str(self.vertical) + \
', ' + str(self.x) + \
', ' + str(self.y) + \
', ' + str(self.name) + ' ]'
def attributes(self):
return [
# self.length,
# self.vertical,
self.x,
self.y,
# self.name
]
def __eq__(self, other):
return self.attributes() == other.attributes()
def fromBlock(optimal_block):
return OptimalBlock(
optimal_block.length,
optimal_block.vertical,
optimal_block.x,
optimal_block.y,
optimal_block.name
)