コード例 #1
0
ファイル: tactic.py プロジェクト: ashishkg0022/tactics_py
class Tactic(object):
    # this default time is in milliseconds
    __metaclass__ = ABCMeta

    DEFAULT_TIMEOUT_PERIOD = 50
    param = tactics_union.Param()

    def __init__(self, bot_id, state, param=None):

        # TO DO based on when param is None , use state to decide the param
        self.bot_id = bot_id
        self.time_out = DEFAULT_TIMEOUT_PERIOD
        self.begin_time = time.time()
        self.param = param

    @abstractmethod
    def execute(self, state):
        pass

    @abstractmethod
    def isComplete(self, state):
        pass

    @abstractmethod
    def updateParams(self, state):
        pass
コード例 #2
0
    def __init__(self, pub):
        self.state = BeliefState()
        self.pub = pub
        self.detected = 6
        self.time = time.clock()

        self.role_list = [['' for i in range(2)]
                          for j in range(self.detected + 1)]

        params = tactics_union.Param()

        self.role_list[0][0] = "TAttacker"
        self.role_list[0][1] = params

        self.role_list[1][0] = "TPrimaryDefender"
        self.role_list[1][1] = params

        self.role_list[2][0] = "TMiddleDefender"
        self.role_list[2][1] = params

        self.role_list[3][0] = "TMiddleDefender"
        self.role_list[3][1] = params

        self.role_list[4][0] = "TForward"
        self.role_list[4][1] = params
コード例 #3
0
    def __init__(self, pub):
        self.state = BeliefState()
        self.pub = pub
        self.time = time.clock()
        self.detected = 6
        self.role_list = [['' for i in range(2)] for j in range(self.detected)]

        params = tactics_union.Param()

        params.DribbleTurnPassP.x = -HALF_FIELD_MAXX
        params.DribbleTurnPassP.y = 0

        self.role_list[0][0] = "TDTP"
        self.role_list[0][1] = params

        self.role_list[1][0] = "TStop"
        self.role_list[1][1] = params

        self.role_list[2][0] = "TStop"
        self.role_list[2][1] = params

        self.role_list[3][0] = "TStop"
        self.role_list[3][1] = params

        self.role_list[4][0] = "TStop"
        self.role_list[4][1] = params

        self.role_list[5][0] = "TStop"
        self.role_list[5][1] = params
コード例 #4
0
def debug_subscriber2(state):
    # print("New Call Back")
    global pub
    attacker_id = 0
    params = tactics_union.Param()
    params.PositionP.x = state.homePos[1].x - 200
    params.PositionP.y = state.homePos[1].y + 200
    cur_tactic = TPosition.TPosition(attacker_id, state, params)
    cur_tactic.execute(state, gv, pub)
コード例 #5
0
def debug_subscriber(state):
    # print("New Call Back")
    global pub
    attacker_id = 0
    params = tactics_union.Param()
    params.PositionP.x = state.ballPos.x
    params.PositionP.y = state.ballPos.y
    cur_tactic = TPosition.TPosition(attacker_id + 1, state, params)
    cur_tactic.execute(state, gv, pub)
コード例 #6
0
    def tactic_instance(self):
        tactic = {0:"TStop", 1:"TStop", 2:"TStop", 3:"TStop", \
            4:"TStop", 5:"TStop"}
        parameters = dict()
        params = tactics_union.Param()
        for i in range(self.active_robots):
            parameters[i] = params

        RefPlay.tactic_instance(self, tactic, parameters)
コード例 #7
0
    def __init__(self, state, publisher):
        tactic = {0:"TPosition", 1:"TPosition", 2:"TPosition", 3:"TPosition", \
                  4:"TPosition", 5:"TPosition"}

        positions = [[0, 0, 0, 0], [1000, 1000, 0, 0], [2000, 2000, 0, 0],
                     [3000, 3000, 0, 0], [-1000, -1000, 0, 0],
                     [-2000, -2000, 0, 0]]
        parameters = dict()
        for i in range(6):
            params = tactics_union.Param()
            params.PositionP.x = positions[i][0]
            params.PositionP.y = positions[i][1]
            params.PositionP.finalSlope = positions[i][2]
            params.PositionP.finalVelocity = positions[i][3]
            parameters[i] = params
        RefPlay.__init__(self, state, tactic, parameters, publisher)
コード例 #8
0
    def tactic_instance(self):
        tactic = {0:"TPosition", 1:"TPosition", 2:"TPosition", 3:"TPosition", \
            4:"TPosition", 5:"TPosition"}

        positions = [[-1000, 0, 0, 0], [-1000, -1000, 0,
                                        0], [-1000, 1000, 0, 0],
                     [3000, 000, 0, 0], [3000, 2000, 0, 0],
                     [3000, -2000, 0, 0]]
        parameters = dict()
        for i in range(6):
            params = tactics_union.Param()
            params.PositionP.x = positions[i][0]
            params.PositionP.y = positions[i][1]
            params.PositionP.finalSlope = positions[i][2]
            params.PositionP.finalVelocity = positions[i][3]
            parameters[i] = params
        RefPlay.tactic_instance(self, tactic, parameters)
コード例 #9
0
 def __init__(self, state, publisher):
     params = tactics_union.Param()
     tactic = {
         0: "TStop",
         1: "TStop",
         2: "TStop",
         3: "TStop",
         4: "TStop",
         5: "TStop"
     }
     params = {
         0: params,
         1: params,
         2: params,
         3: params,
         4: params,
         5: params
     }
     RefPlay.__init__(self, state, tactic, params, publisher)
コード例 #10
0
    def __init__(self):
        self.state = BeliefState() 
        self.detected = 6
        
        self.Tactic_0 = False
        self.Tactic_1 = False
        self.Tactic_2 = False
        self.Tactic_3 = False
        self.Tactic_4 = False
        self.Tactic_5 = False

        self.role_list = [['' for i in range(2)] for j in range(self.detected+1)]

        params = tactics_union.Param()
        params.IntercptP.awayBotID = 3
        params.IntercptP.where = 0
        
        self.role_list[0][0] = "TTestIt"
        self.role_list[0][1] = params

        self.role_list[1][0] = "TReceiver"
        self.role_list[1][1] = params
コード例 #11
0
test_roles.role_list[3][1] = params

params = tactics_union.Param()
params.PositionP.x = -200.0
params.PositionP.y = -200.0
params.PositionP.finalSlope = 0.0
params.PositionP.finalVelocity = 0.0
params.PositionP.align = False
test_roles.role_list[4][0] = "TPosition"
test_roles.role_list[4][1] = params

params = tactics_union.Param()
params.PositionP.x = 450.0
params.PositionP.y = 450.0
params.PositionP.finalSlope = 0.0
params.PositionP.finalVelocity = 0.0
params.PositionP.align = False
test_roles.role_list[5][0] = "TPosition"
test_roles.role_list[5][1] = params

'''
params = tactics_union.Param()
params.IntercptP.awayBotID = 3
params.IntercptP.where = 0
test_roles.role_list[0][0] = "TPosition"
test_roles.role_list[0][1] = params


print 'Initializing the node...'
test_roles.node()