-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (38 loc) · 1.24 KB
/
main.py
File metadata and controls
48 lines (38 loc) · 1.24 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
48
#
# Behavior Tree framework for A1 Behavior trees assignment.
# CS131 - Artificial Intelligence
#
# version 1.0.2 - copyright (c) 2023 Santini Fabrizio. All rights reserved.
#
import bt_library as btl
from battery_less_than_30 import BatteryLessThan30
from find_home import FindHome
from globals import BATTERY_LEVEL, GENERAL_CLEANING, SPOT_CLEANING, DUSTY_SPOT_SENSOR, HOME_PATH
# Instantiate the tree according to the assignment. The following are just examples.
# tree_root = btl.Timer(5, FindHome())
tree_root = btl.Sequence(
[
BatteryLessThan30(),
btl.Timer(10, FindHome())
]
)
# tree_root = btl.Sequence(
# [
# BatteryLessThan30(),
# FindHome()
# ]
# )
# Main body of the assignment
current_blackboard = btl.Blackboard()
current_blackboard.set_in_environment(BATTERY_LEVEL, 29)
current_blackboard.set_in_environment(SPOT_CLEANING, False)
current_blackboard.set_in_environment(GENERAL_CLEANING, True)
current_blackboard.set_in_environment(DUSTY_SPOT_SENSOR, False)
current_blackboard.set_in_environment(HOME_PATH, "")
cycles = 10
while cycles > 0:
# Change the environment
# Evaluating the tree
result = tree_root.run(current_blackboard)
# Going through the cycles
cycles = cycles - 1