Пример #1
0
    def makeController(self, bot, current=None):
        self.mines = [
            drobots.Point(x=100, y=100),
            drobots.Point(x=100, y=300),
            drobots.Point(x=300, y=100),
            drobots.Point(x=300, y=300),
        ]
        """
        makeController is invoked by the game server. The method receives a
        "bot", instance of RobotPrx.

        It is mandatory to return a direct proxy, in case that you are using
        IceGrid
        """

        print("Make controller received bot {}".format(bot))
        if bot.ice_isA("::drobots::Attacker"):
            controller = RobotControllerAttacker(bot, self.mines)
            object_prx = current.adapter.addWithUUID(controller)
            controller_prx = current.adapter.createDirectProxy(
                object_prx.ice_getIdentity())
            controller_prx = drobots.RobotControllerPrx.checkedCast(
                controller_prx)

        elif (bot.ice_isA("::drobots::Defender")):
            controller = RobotControllerDefender(bot, self.mines)
            object_prx = current.adapter.addWithUUID(controller)
            controller_prx = current.adapter.createDirectProxy(
                object_prx.ice_getIdentity())
            controller_prx = drobots.RobotControllerPrx.checkedCast(
                controller_prx)

        self.controllers += 1
        self._set_bot_prx(controller_prx)
        return controller_prx
Пример #2
0
 def __init__(self, container):
     self.detector_controller = None
     self.mine_index = 0
     self.mines = [
         drobots.Point(x=100, y=100),
         drobots.Point(x=100, y=300),
         drobots.Point(x=300, y=100),
         drobots.Point(x=300, y=300),
     ]
     self.robotsContainer = container
Пример #3
0
 def __init__(self, container_prx):
     self.container_prx = container_prx
     self.detector_controller = None
     self.controllers = 0
     self.mine_index = 0
     self.mines = [
         drobots.Point(x=100, y=100),
         drobots.Point(x=100, y=300),
         drobots.Point(x=300, y=100),
         drobots.Point(x=300, y=300),
     ]
Пример #4
0
 def __init__(self, container_prx):
     self.container_prx = container_prx
     self.controller_factory_prx_1 = self.__get_controller_factory_prx(1)
     self.controller_factory_prx_2 = self.__get_controller_factory_prx(2)
     self.detector_factory_prx_1 = self.__get_detector_factory_prx()
     self.mine_index = 0
     self.mines = [
         drobots.Point(x=100, y=100),
         drobots.Point(x=100, y=300),
         drobots.Point(x=300, y=100),
         drobots.Point(x=300, y=300),
     ]
Пример #5
0
 def __init__(self, participante, cont):
     self.participante = participante
     self.cont = cont
     self.count = 0
     self.countDetec = 0
     self.countMinas = 0
     self.mines = [
         drobots.Point(x=100, y=100),
         drobots.Point(x=100, y=300),
         drobots.Point(x=300, y=100),
         drobots.Point(x=300, y=300),
     ]
Пример #6
0
    def getMinePosition(self, current=None):
        x = random.randint(0, 399)
        y = random.randint(0, 399)
        pos = drobots.Point(x, y)

        while pos in self.mines:
            x = random.randint(0, 399)
            y = random.randint(0, 399)
            pos = drobots.Point(x, y)

        self.mines.append(pos)
        self.mine_index += 1

        return pos
Пример #7
0
 def __init__(self, adapter, sirv, sorv):
     self.adaptador = adapter
     self.con = sirv
     self.con1 = sorv
     self.contadorCreados = 0
     self.contadorRobots = 0
     self.detector_controller = None
     self.mine_index = 0
     self.mines = [
         drobots.Point(x=randint(0, 199), y=randint(0, 199)),
         drobots.Point(x=randint(200, 399), y=randint(0, 199)),
         drobots.Point(x=randint(0, 199), y=randint(200, 399)),
         drobots.Point(x=randint(200, 399), y=randint(200, 399)),
     ]
Пример #8
0
 def __init__(self, bot, contador):
     self.robot = bot
     self.turnos = 0
     self.angulo = 0
     self.id = contador
     self.posicionactual = drobots.Point(0,0)
     print("Robot"+str(self.id)+" de defensa creado.")
Пример #9
0
 def disparoAleatorio(self, posicion, current=None):
     print("Calculando disparo aleatorio")
     self.posAttack = drobots.Point(random.randint(0, 999),
                                    random.randint(0, 999))
     x = self.posAttack.x - posicion.x
     y = self.posAttack.y - posicion.y
     self.anguloDisparo = int(math.degrees(math.atan2(y, x)))
     self.distancia = self.distanciaAliados(posicion, self.posAttack)
Пример #10
0
 def getMinePosition(self, current):
     print("JUGADOR 1: " + str(self.name) + "--> creando mina: " +
           str(self.contMin))
     mina = drobots.Point(random.randint(0, 399), random.randint(0, 399))
     self.containerMinas.link2(
         str(self.name) + " Mina " + str(self.contMin), mina)
     self.contMin += 1
     print()
     return mina
Пример #11
0
    def __init__(self, bot, contA, current=None):
        self.bot = bot
        self.energia = 100
        self.enMovimiento = False
        self.siDetectado = False
        self.aliadoCerca = False
        self.distanciaCorrecta = True
        self.anguloDisparo = 0
        self.anguloScan = 0
        self.distancia = 0
        self.aumentarDistancia = 100
        self.aumentarDistancia2 = 0
        self.anchuraScan = 20
        self.posAttack = drobots.Point(random.randint(0, 999),
                                       random.randint(0, 999))
        self.posAliado = drobots.Point(-1, -1)
        self.tipo = "Attacker"
        self.contA = contA
        self.isDestroyed = False
        self.robotsDefend = []
        self.robotsAttack = []

        print("¡Robot ATAQUE listo para el combate!")
Пример #12
0
    def __init__(self, bot, contD, current=None):
        self.bot = bot
        self.energia = 100
        self.enMovimiento = False
        self.angulo = random.randint(0, 359)
        self.anchuraScan = 20
        self.contador = 0
        self.posAliado = drobots.Point(-1, -1)
        self.tipo = "Defender"
        self.contD = contD
        self.isDestroyed = False
        self.robotsDefend = []
        self.robotsAttack = []

        print("¡Robot DEFENSA listo para el combate!")
Пример #13
0
 def createMines(self):
     mines = []
     for i in range(0, 4):
         mine = random.sample(range(0, 399), 2)
         mines.append(drobots.Point(x=mine[0], y=mine[1]))
     return mines