예제 #1
0
    def test_setters(self):
        mobile = CMobile()
        vector = Vector3D(x=1, y=2, z=3)
        mobile.setDestination(vector)

        self.assertEqual(mobile.m_Destination.x, vector.x)

        self.assertEqual(mobile.m_Destination.y, vector.y)

        self.assertEqual(mobile.m_Destination.z, vector.z)
예제 #2
0
    def test_calculate_position(self):
        dt = 0.001
        mobile = CMobile()
        mobile.m_Velocity = Vector3D(x=10, y=20, z=30)
        mobile.CalculatePosition(dt)

        self.assertEqual(mobile.m_Position.x, mobile.m_Velocity.x * dt)

        self.assertEqual(mobile.m_Position.y, 0)

        self.assertEqual(mobile.m_Position.z, mobile.m_Velocity.z * dt)
예제 #3
0
    def test_set_size(self):
        max_x = 5
        max_z = 10
        mobile = CMobile()
        mobile.SetSize(max_x, max_z)

        self.assertEqual(mobile.m_MinX, 8)

        self.assertEqual(mobile.m_MinZ, 8)

        self.assertEqual(mobile.m_MaxX, (max_x * 8) - 8)

        self.assertEqual(mobile.m_MaxZ, (max_z * 8) - 8)
예제 #4
0
    def test_calculate_new_destination(self):
        mobile = CMobile()
        radio_x = 10
        radio_y = 20
        max_x = 5
        max_z = 10
        mobile.SetSize(max_x, max_z)
        mobile.CalculateNewDestination(radio_x, radio_y)

        self.assertNotEqual(mobile.m_Destination.x, 0)

        self.assertEqual(mobile.m_Destination.y, 0)

        self.assertNotEqual(mobile.m_Destination.z, 0)
예제 #5
0
    def test_calculate_new_orientation(self):
        mobile = CMobile()
        x = 10
        y = 20
        z = 30
        mobile.m_Destination = Vector3D(x=x, y=y, z=z)
        mobile.CalculateNewOrientation()
        leng = math.sqrt((x * x + y * y + z * z))

        self.assertEqual(mobile.m_Heading.x, x / leng)

        self.assertEqual(mobile.m_Heading.y, y / leng)

        self.assertEqual(mobile.m_Heading.z, z / leng)
예제 #6
0
파일: CTroop.py 프로젝트: gti-ia/pgomas
        async def run(self):
            msg = await self.receive(timeout=1000000)
            if msg is None:
                print("[" + self.agent.name + "]: Warning! Cannot begin")
                self.agent.stop()
                return
            else:
                tokens = msg.body.split()
                s_map_name = None
                for token in tokens:
                    if token == "MAP:":
                        s_map_name = tokens[tokens.index(token) + 1]
                print("[" + self.agent.name + "]: Beginning to fight")
                if not s_map_name:
                    return
                self.agent.m_Map = CTerrainMap()
                config = CConfig()
                self.agent.m_Map.LoadMap(s_map_name, config)
                self.agent.m_Movement = CMobile()
                self.agent.m_Movement.SetSize(self.agent.m_Map.GetSizeX(),
                                              self.agent.m_Map.GetSizeZ())

                self.agent.generate_spawn_position()
                self.agent.SetUpPriorities()

                # Behaviour to get the objective of the game, to create the corresponding task
                t = Template()
                t.set_metadata("performative", "objective")
                self.agent.add_behaviour(self.agent.ObjectiveBehaviour(), t)

                # Behaviour to listen to manager if game has finished
                t = Template()
                t.set_metadata("performative", "game")
                self.agent.add_behaviour(self.agent.GameFinishedBehaviour(), t)

                # Behaviour to handle Pack Taken messages
                t = Template()
                t.set_metadata("performative", "pack_taken")
                self.agent.add_behaviour(self.agent.PackTakenBehaviour(0), t)

                # Behaviour to handle Shot messages
                t = Template()
                t.set_metadata("performative", "shot")
                self.agent.add_behaviour(self.agent.PackTakenBehaviour(0), t)

                # Behaviour to inform JGomasManager our position, status, and so on
                self.agent.add_behaviour(
                    self.agent.DataFromTroopBehaviour(0.1))

                # Behaviour to increment inner variables (Power, Stamina and Health Bars)
                #self.agent.Launch_BarsAddOn_InnerBehaviour()
                self.agent.add_behaviour(self.agent.RestoreBehaviour(1))

                # Behaviour to call for medics or fieldops
                self.agent.add_behaviour(
                    self.agent.MedicAmmoRequestBehaviour(1))

                # // Behaviour to launch the FSM
                self.agent.Launch_FSM_Behaviour()
예제 #7
0
파일: CManager.py 프로젝트: gti-ia/pgomas
 def __init__(self, ):
     self.m_JID = ""
     self.m_eTeam = 0
     self.m_Locate = CMobile()
     self.m_bCarryingObjective = False
     self.m_bShooting = False
     self.m_iHealth = 0
     self.m_iAmmo = 0
     self.m_eType = 0
예제 #8
0
    def test_getters(self):
        mobile = CMobile()

        destination = mobile.getDestination()
        position = mobile.getPosition()
        angle = mobile.getdAngle()
        radius = mobile.getdViewRadius()
        heading = mobile.getHeading()
        velocity = mobile.getVelocity()

        self.assertIsInstance(destination, Vector3D)

        self.assertIsInstance(position, Vector3D)

        self.assertEqual(angle, 1)

        self.assertEqual(radius, 50)

        self.assertIsInstance(heading, Vector3D)

        self.assertIsInstance(velocity, Vector3D)