-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_task_4.py
41 lines (35 loc) · 1.26 KB
/
test_task_4.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
from arc_tools.grid import Grid, Color
from arc_tools.plot import plot_grid, plot_grids
from task_4 import shoot_light
def test_shoot_light():
# Create a test grid with L-shaped objects and target objects
test_grid = [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 2, 0],
[0, 0, 0, 0, 0, 0, 2, 0],
]
grid = Grid(test_grid)
plot_grid(grid, name="input.png", show=True)
result = shoot_light(grid)
plot_grid(result, name="output.png", show=True)
# Expected output should have:
# 1. Yellow light path from L-shape
# 2. Red light path after hitting the red object
expected = [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 4, 4, 4, 4, 4, 4],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 2, 0],
[0, 0, 0, 0, 0, 0, 2, 0],
]
assert result == Grid(expected), "Test failed: Output does not match expected result"
if __name__ == "__main__":
test_shoot_light()