-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_main.py
More file actions
27 lines (23 loc) · 856 Bytes
/
test_main.py
File metadata and controls
27 lines (23 loc) · 856 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
import json
d = [[0, 0, 0, 0, 0, 0, 0], [0, 8, 8, 8, 8, 8, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 6, 6, 6, 6, 6, 0], [0, 0, 0, 0, 0, 0, 0]]
d = json.load(open("grid1.json"))
from arc_tools.grid import Grid, detect_objects
from main import merge_nearby_objects_as_square
d = Grid(d)
for i in range(0,22):
for j in range(0,30):
d[i][j] = 0
objs = detect_objects(d)
print('Before merge')
print(len(objs))
for i in range(len(objs)):
print(objs[i].region)
objs = merge_nearby_objects_as_square(objs,0)
# d.save()
print('After merge')
print(len(objs))
for i in range(len(objs)):
print(objs[i].region)
# plot_grids([d,*objs], show=1 )
# assert region 1,1 to 5,5 is 1
# assert objs[0].region == GridRegion([GridPoint(1, 1), GridPoint(5, 5)]), f"Region is {objs[0].region}"