Trees | Indices | Help |
---|
|
1 ################################################################################## 2 # Copyright (c) 2010, 2011, 2012, 2013, Daniel Urieli, Peter Stone 3 # University of Texas at Austin 4 # All right reserved 5 # 6 # Based On: 7 # 8 # Copyright (c) 2000-2003, Jelle Kok, University of Amsterdam 9 # All rights reserved. 10 # 11 # Redistribution and use in source and binary forms, with or without 12 # modification, are permitted provided that the following conditions are met: 13 # 14 # 1. Redistributions of source code must retain the above copyright notice, this 15 # list of conditions and the following disclaimer. 16 # 17 # 2. Redistributions in binary form must reproduce the above copyright notice, 18 # this list of conditions and the following disclaimer in the documentation 19 # and/or other materials provided with the distribution. 20 # 21 # 3. Neither the name of the University of Amsterdam nor the names of its 22 # contributors may be used to endorse or promote products derived from this 23 # software without specific prior written permission. 24 # 25 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 ################################################################################## 36 37 38 39 import random 40 41 ######################################################################## 42 # This file contains factory functions that are used in main.py 43 # to allocate objects based on cmd line options 44 ######################################################################## 45 46 47 ################################################### 48 # AgentStrategy Factories. 49 # All should have an create(self, agentIndex) function 50 ################################################### 51 #TODO: We might need to send specific data do different strategies. 52 # This can be done using the **args method. 53 # However, we don't do it yet as it's just an experimental mode, 54 # and anyway allocation method might be changed later 55 56 import agents 57 import state 61667068 agentPath = self.paths[agentIndex] # assuming path of length 2 69 return agents.AgentRRTStrategy(agentIndex, agentPath[0], agentPath[1], self.rulesOfTheSea)7478 79 #class MeasureEdgeLengthsFactory: 80 # def create(self, agentIndex): 81 # #TODO: this class is a hack, find better way to allocate and combine 82 # 83 # 84 # ############## goalPos=(random.randint(0,1200), random.randint(0,600)) 85 # goalPos=(1100, 300) 86 # 87 # 88 # 89 # agentStrategy = agents.AgentPIDStrategy(agentIndex, 90 # goalPos) 91 # return agents.MeasureEdgeLengths(agentIndex, goalPos, agentStrategy) 92 93 10176 return agents.AgentPIDStrategy(agentIndex, 77 (random.randint(0,1200), random.randint(0,600)), self.rulesOfTheSea)110104 self.patrolPoints = patrolPoints 105 self.edgeLengths = edgeLengths 106 self.rulesOfTheSea = rulesOfTheSea107109 return agents.AgentCoordinatedPatrolStrategy(agentIndex, self.patrolPoints, self.edgeLengths, self.rulesOfTheSea)119 120113 self.patrolPoints = patrolPoints 114 self.edgeLengths = edgeLengths 115 self.rulesOfTheSea = rulesOfTheSea116118 return agents.AgentJoiningPatrolStrategy(agentIndex, self.patrolPoints, self.edgeLengths, self.rulesOfTheSea)134 135 # class AgentRandomPatrolStrategyFactory: 136 # def __init__(self, patrolArea, rulesOfTheSea): 137 # self.patrolArea = patrolArea 138 # self.rulesOfTheSea = rulesOfTheSea 139 # 140 # def create(self, agentIndex): 141 # return agents.AgentRandomPatrolStrategy(agentIndex, self.patrolArea, self.rulesOfTheSea) 142 143 144 145 ################################################### 146 # AgentWorldModel Factories. 147 # All should have an create(self) function 148 ################################################### 149 import agents 153 154 155 156 157 ################################################### 158 # Ship Factories. 159 # All should have an create(self) function 160 ################################################### 161 import shipModels 165122 - def __init__(self, trackedShipIndices, trackingShipIndices, trackingDistance, 123 positionOffsets, rulesOfTheSea):124 self.trackedShipIndices = trackedShipIndices 125 self.trackingShipIndices = trackingShipIndices 126 self.trackingDistance = trackingDistance 127 self.positionOffsets = positionOffsets 128 self.rulesOfTheSea = rulesOfTheSea129131 return agents.AgentTrackingPatrolStrategy(agentIndex, 132 self.trackedShipIndices, self.trackingShipIndices, 133 self.trackingDistance, self.positionOffsets, self.rulesOfTheSea)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Nov 14 13:01:28 2013 | http://epydoc.sourceforge.net |