-
Notifications
You must be signed in to change notification settings - Fork 6
/
PredatorBrain.py
48 lines (34 loc) · 1.38 KB
/
PredatorBrain.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
42
43
44
45
46
47
48
'''
(c) 2015 Georgia Tech Research Corporation
This source code is released under the New BSD license. Please see the LICENSE.txt file included with this software for more information
authors: Arindam Bose ([email protected]), Tucker Balch ([email protected])
'''
from Agent import Agent
from Ball import Ball
from Obstacle import Obstacle
from LinearAlegebraUtils import *
import numpy as np
from Action import Stun, Kick
import random
from NavUtils import getObstacleAvoidance, findNearestUnstunned, getTeamAvoidance
class PredatorBrain(object):
'''
classdocs
'''
def __init__(self):
pass
def takeStep(self, myTeam=[], enemyTeam=[], balls=[], obstacles=[]):
actions = []
deltaPos = np.array([1, 0, 0])
nearestUnstunnedAgent = findNearestUnstunned(enemyTeam)
stunMovement = array([0, 0, 0])
if nearestUnstunnedAgent.isStunned:
stunMovement = array([0, 0, 0])
else:
stunMovement = nearestUnstunnedAgent.position
avoidObstacleMovement = getObstacleAvoidance(obstacles)
avoidTeamMovement = getTeamAvoidance(myTeam)
movement = normalize(1.5*stunMovement + 0.5*avoidObstacleMovement + 0.5*avoidTeamMovement)
deltaRot = getYPRFromVector(movement)
actions.append(Stun(nearestUnstunnedAgent, 5))
return deltaPos, deltaRot, actions