forked from oddaspa/Oving6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arbitrator.py
34 lines (23 loc) · 998 Bytes
/
arbitrator.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
class Arbitrator():
def __init__(self,behaviors):
self.behaviors = behaviors
self.halt_flag = False
# getting the most valuable behavior
def get_behavior(self):
max_weighted_behavior = None
max_weight = -1
for behavior in self.behaviors:
if behavior.halt_flag:
self.halt_flag = True
return behavior
if behavior.weight > max_weight:
max_weight = behavior.weight
max_weighted_behavior = behavior
return max_weighted_behavior
# Regardless of the selection strategy, choose action should return a tuple
# containing: 1. motor recommendations(one per motob) to move the robot,
# and 2. a boolean indicating whether or not the run should be halted.
def choose_action(self):
behavior = self.get_behavior()
motor_recommendation = behavior.motor_recommandations
return (motor_recommendation, self.halt_flag)