Exemplo n.º 1
0
# Create a Colorfight Instance. This will be the object that you interact
# with.
game = Colorfight()

# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room='public4')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to seuut a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change
# between runs so you can continue the game if disconnected.
if game.register(username = '******', \
  password = str(int(time.time()))):
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack,
        #this is here so that you dont attack the same ome multiple times (BAD!)
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
Exemplo n.º 2
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS

# Create a Colorfight Instance. This will be the object that you interact
# with.
game = Colorfight()

# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room='public2')



if game.register(username = '******', \
        password = "******"):

    game.update_turn()
    print(game.game_map[29, 29].owner)
    """
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be 
        # in the game after one round.
Exemplo n.º 3
0
game.connect(room='Acropolis')

#Musikverein
#public
#Acropolis

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change
# between runs so you can continue the game if disconnected.
i = 1
while (True):
    if game.register(username = '******', \
            password = '******'):
        # This is the game loop
        while True:
            # The command list we will send to the server
            cmd_list = []
            # The list of cells that we want to attack
            my_attack_list = []
            # update_turn() is required to get the latest information from the
            # server. This will halt the program until it receives the updated
            # information.
            # After update_turn(), game object will be updated.
            last_turn = game.turn
            game.update_turn()

            # Turn number does not go back. So if it is going back, that means
            # a new game. You can add a infinite loop to continuously register
Exemplo n.º 4
0
def sortFirst(y):
    return (y.attack_cost / (2 * y.energy) + (y.attack_cost / 6 * y.gold))


def sortSecond(x):
    return (x.attack_cost / (1 * x.energy) + (x.attack_cost / 2 * x.gold))


# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change
# between runs so you can continue the game if disconnected.
if game.register(username = '******', \
        password = "******" ):#, join_key="66466"):
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
        # in the game after one round.
Exemplo n.º 5
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS, BLD_HOME

game = Colorfight()
game.connect(room='groupd')

if game.register(username = '******', \
        password = '******'):
    while True:
        cmd_list = []
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
        # in the game after one round.
        if game.me == None:
            continue

        me = game.me

        # game.me.cells is a dict, where the keys are Position and the values
        # are MapCell. Get all my cells.
        newlist = list()
        for i in game.me.cells.values():
Exemplo n.º 6
0
# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room = 'public4')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change 
# between runs so you can continue the game if disconnected.




if game.register(username = '******', \
        password = '******'):
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information. 
        # After update_turn(), game object will be updated.   
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be 
        # in the game after one round.
Exemplo n.º 7
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS

from ai1 import ai1
from petry_ai import ai_petry

gamers = []
for gamer_id in range(8):

    # register
    game = Colorfight()
    game.connect(room='public')
    game.register(username='******' + str(gamer_id), password='******')

    # param

    param = [1]
    for i in range(14):
        param.append(random.random() * 100 - 50)
    with open("param.txt", "a") as f:
        f.write(str(gamer_id))
        f.write(' ')
        f.write(str(param))
        f.write('\n')
        f.close()

    game.param = param
    gamers.append(game)
Exemplo n.º 8
0
# Create a Colorfight Instance. This will be the object that you interact
# with.
game = Colorfight()

# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room='public2')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change
# between runs so you can continue the game if disconnected.
if game.register(username = '******', \
        password = str(int(time.time()))):
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []

        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
Exemplo n.º 9
0
from colorfight import Colorfight
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS

from petry_ai import ai_petry

game = Colorfight()
game.connect(room='final')
game.register(username='******', password='******')

if not game.me:
    game.connect(room='final')
    game.register(username='******', password='******')

    # This is the game loop
while True:
    game.update_turn()

    params = [
        1, -18.53341319688236, -0.8219475924979506, 2.2963243078751745,
        -2.12995591256858, -5.172858499022022, 16.968696086066522,
        -1.4114154156601832, -1.0770153231601682, -12.082107075648503,
        -2.1421765673156354, 18.795280713849472, 14.66617744870164,
        -0.39348099194405034, 4.819134378406117, 17.67588494142681,
        -31.470563592117514
    ]
    cmd_list = ai_petry(game, params)

    result = game.send_cmd(cmd_list)
    print(result)
Exemplo n.º 10
0
# Create a Colorfight Instance. This will be the object that you interact
# with.
game = Colorfight()

# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room='final')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change
# between runs so you can continue the game if disconnected.
if game.register(username = '******', \
        password = str(int(time.time()))):
    # This is the game loop

    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
Exemplo n.º 11
0
class Inevitable:
    def __init__(self):
        self.game = Colorfight()
        pass

    def Start(self):
        self.defenseEnergy = 1
        self.attackEnergy = 0
        self.energyChance = 2
        self.rechargeNow = False
        self.command = ""
        self.hold = False
        self.game.connect(room='final')
        if self.game.register(username='******', password="******"):
            self.starkThread = Thread(target=self.Stark)
            self.starkThread.start()
            while True:
                if self.Refresh():
                    self.FetchInfo()
                    self.GameLoop()
                    self.Send()

    def GetCell(self, pos):
        return self.game.game_map[pos]

    def GetUser(self, uid):
        return self.game.users[uid]

    def Attack(self, cell, energy=None):
        if energy == None:
            energy = cell.attack_cost + self.attackEnergy
        self.me.energy -= energy
        self.cmdList.append(self.game.attack(cell.position, energy))
        self.attackList.append(cell.position)

    def Upgrade(self, cell):
        cellType = cell.building.name
        cellLevel = cell.building.level
        if cellType == "home":
            if cellLevel == 1:
                self.me.energy -= HOME_I[0]
                self.me.gold -= HOME_I[1]
            elif cellLevel == 2:
                self.me.energy -= HOME_II[0]
                self.me.gold -= HOME_II[1]
        elif cellType == "energy_well":
            if cellLevel == 1:
                self.me.energy -= ENERGY_I[0]
                self.me.gold -= ENERGY_I[1]
            elif cellLevel == 2:
                self.me.energy -= ENERGY_II[0]
                self.me.gold -= ENERGY_II[1]
        elif cellType == "gold_mine":
            if cellLevel == 1:
                self.me.energy -= GOLD_I[0]
                self.me.gold -= GOLD_I[1]
            elif cellLevel == 2:
                self.me.energy -= GOLD_II[0]
                self.me.gold -= GOLD_II[1]
        elif cellType == "fortress":
            if cellLevel == 1:
                self.me.energy -= FORTRESS_I[0]
                self.me.gold -= FORTRESS_I[1]
            elif cellLevel == 2:
                self.me.energy -= FORTRESS_II[0]
                self.me.gold -= FORTRESS_II[1]
        self.cmdList.append(self.game.upgrade(cell.position))

    def CanSnap(self, base):
        owner = self.GetUser(base.owner)
        if self.me.energy >= (owner.energy_source + base.attack_cost):
            return owner.energy_source + base.attack_cost
        else:
            return -1

    def CanBuild(self, building):
        if building == BLD_ENERGY_WELL:
            return self.me.energy >= ENERGY_I[0] and self.me.gold >= ENERGY_I[1]
        elif building == BLD_GOLD_MINE:
            return self.me.energy >= GOLD_I[0] and self.me.gold >= GOLD_I[1]
        elif building == BLD_FORTRESS:
            return self.me.energy >= FORTRESS_I[
                0] and self.me.gold >= FORTRESS_I[1]

    def CanUpgrade(self, cell):
        cellType = cell.building.name
        cellLevel = cell.building.level
        if cellType == "home":
            if cellLevel == 1:
                return self.me.energy >= HOME_I[0] and self.me.gold >= HOME_I[1]
            elif cellLevel == 2:
                return self.me.energy >= HOME_II[
                    0] and self.me.gold >= HOME_II[1]
            else:
                return False
        elif cellType == "energy_well":
            if cellLevel == 1:
                return self.me.energy >= ENERGY_I[
                    0] and self.me.gold >= ENERGY_I[1]
            elif cellLevel == 2:
                return self.me.energy >= ENERGY_II[
                    0] and self.me.gold >= ENERGY_II[1]
            else:
                return False
        elif cellType == "gold_mine":
            if cellLevel == 1:
                return self.me.energy >= GOLD_I[0] and self.me.gold >= GOLD_I[1]
            elif cellLevel == 2:
                return self.me.energy >= GOLD_II[
                    0] and self.me.gold >= GOLD_II[1]
            else:
                return False
        elif cellType == "fortress":
            if cellLevel == 1:
                return self.me.energy >= FORTRESS_I[
                    0] and self.me.gold >= FORTRESS_I[1]
            elif cellLevel == 2:
                return self.me.energy >= FORTRESS_II[
                    0] and self.me.gold >= FORTRESS_II[1]
            else:
                return False

    def Build(self, cell, building):
        if building == BLD_ENERGY_WELL:
            self.me.energy -= ENERGY_I[0]
            self.me.gold -= ENERGY_I[1]
        elif building == BLD_GOLD_MINE:
            self.me.energy -= GOLD_I[0]
            self.me.gold -= GOLD_I[1]
        elif building == BLD_FORTRESS:
            self.me.energy -= FORTRESS_I[0]
            self.me.gold -= FORTRESS_I[1]
        self.cmdList.append(self.game.build(cell.position, building))

    def FetchAdjacent(self, cell):
        return [
            self.game.game_map[pos]
            for pos in cell.position.get_surrounding_cardinals()
        ]

    def Empty(self, cell):
        return cell.owner == 0

    def Own(self, cell):
        return cell.owner == self.game.uid

    def Enemy(self, cell):
        return not (cell.owner == 0 or cell.owner == self.game.uid)

    def FetchInfo(self):
        self.me = self.game.me
        self.mode = 0
        self.tech = 0

        self.data = {}

        self.data["adjacent"] = {}
        self.data["adjacent"]["all"] = set()
        self.data["adjacent"]["empty"] = set()
        self.data["adjacent"]["enemy"] = {}
        self.data["adjacent"]["enemy"]["all"] = set()
        self.data["adjacent"]["enemy"]["empty"] = set()
        self.data["adjacent"]["enemy"]["energy"] = [set(), set(), set()]
        self.data["adjacent"]["enemy"]["gold"] = [set(), set(), set()]
        self.data["adjacent"]["enemy"]["bases"] = [set(), set(), set()]
        self.data["adjacent"]["enemy"]["forts"] = [set(), set(), set()]

        self.data["own"] = {}
        self.data["own"]["all"] = set()
        self.data["own"]["empty"] = set()
        self.data["own"]["energy"] = [set(), set(), set()]
        self.data["own"]["gold"] = [set(), set(), set()]
        self.data["own"]["bases"] = [set(), set(), set()]
        self.data["own"]["forts"] = [set(), set(), set()]

        self.data["edges"] = set()

        self.data["enemy"] = {}
        self.data["enemy"]["all"] = set()
        self.data["enemy"]["empty"] = set()
        self.data["enemy"]["energy"] = [set(), set(), set()]
        self.data["enemy"]["gold"] = [set(), set(), set()]
        self.data["enemy"]["bases"] = [set(), set(), set()]
        self.data["enemy"]["forts"] = [set(), set(), set()]

        self.cmdList = []
        self.attackList = []

        for x in range(30):
            for y in range(30):
                pos = Position(x, y)
                cell = self.GetCell(pos)
                if self.Own(cell):
                    self.data["own"]["all"].add(pos)
                    cellType = cell.building.name
                    if cellType == "empty":
                        self.data["own"]["empty"].add(pos)
                    elif cellType == "home":
                        self.data["own"]["bases"][cell.building.level -
                                                  1].add(pos)
                    elif cellType == "energy_well":
                        self.data["own"]["energy"][cell.building.level -
                                                   1].add(pos)
                    elif cellType == "gold_mine":
                        self.data["own"]["gold"][cell.building.level -
                                                 1].add(pos)
                    elif cellType == "fortress":
                        self.data["own"]["forts"][cell.building.level -
                                                  1].add(pos)
                    for adj in self.FetchAdjacent(cell):
                        if not self.Own(adj):
                            self.data["adjacent"]["all"].add(adj.position)
                            if self.Enemy(adj):
                                self.data["edges"].add(pos)
                                self.data["adjacent"]["enemy"]["all"].add(
                                    adj.position)
                                adjType = adj.building.name
                                if adjType == "empty":
                                    self.data["enemy"]["empty"].add(
                                        adj.position)
                                elif adjType == "home":
                                    self.data["enemy"]["bases"][
                                        adj.building.level - 1].add(
                                            adj.position)
                                elif adjType == "energy_well":
                                    self.data["enemy"]["energy"][
                                        adj.building.level - 1].add(
                                            adj.position)
                                elif adjType == "gold_mine":
                                    self.data["enemy"]["gold"][
                                        adj.building.level - 1].add(
                                            adj.position)
                                elif adjType == "fortress":
                                    self.data["enemy"]["forts"][
                                        adj.building.level - 1].add(
                                            adj.position)
                            else:
                                self.data["adjacent"]["empty"].add(
                                    adj.position)

    def Refresh(self):
        self.game.update_turn()
        return not self.game.me == None

    def Send(self):
        self.game.send_cmd(self.cmdList)

    def Defend(self):
        base = None
        if len(self.data["own"]["bases"][0]) > 0:
            base = self.GetCell(list(self.data["own"]["bases"][0])[0])
        if len(self.data["own"]["bases"][1]) > 0:
            base = self.GetCell(list(self.data["own"]["bases"][1])[0])
        if len(self.data["own"]["bases"][2]) > 0:
            base = self.GetCell(list(self.data["own"]["bases"][2])[0])
        if base:
            self.tech = base.building.level
            if self.CanUpgrade(base):
                self.Upgrade(base)

    def Expand(self):
        if self.me.gold <= 500:
            self.BuildEnergy()
        targets = [self.GetCell(t) for t in self.data["adjacent"]["empty"]]
        targets.sort(key=lambda cell: (cell.natural_energy, -cell.attack_cost),
                     reverse=True)
        for target in targets:
            if target.attack_cost <= self.me.energy:
                self.Attack(target)

    def Bread(self):
        self.BuildGold()
        targets = [self.GetCell(t) for t in self.data["adjacent"]["empty"]]
        targets.sort(key=lambda cell: (cell.natural_gold, -cell.attack_cost),
                     reverse=True)
        for target in targets:
            if target.attack_cost <= self.me.energy:
                self.Attack(target)

    def BuildEnergy(self):
        energyTargets = [self.GetCell(e) for e in self.data["own"]["empty"]]
        energyTargets.sort(key=lambda cell: (cell.natural_energy),
                           reverse=True)
        for energyTarget in energyTargets:
            if self.CanBuild(BLD_ENERGY_WELL):
                self.Build(energyTarget, BLD_ENERGY_WELL)

    def BuildGold(self):
        goldTargets = [self.GetCell(e) for e in self.data["own"]["empty"]]
        goldTargets.sort(key=lambda cell: (cell.natural_gold), reverse=True)
        for goldTarget in goldTargets:
            if self.CanBuild(BLD_GOLD_MINE):
                self.Build(goldTarget, BLD_GOLD_MINE)

    def UpgradeEnergy(self, level):
        energyTargets = [
            self.GetCell(e) for e in self.data["own"]["energy"][level - 1]
        ]
        energyTargets.sort(key=lambda cell: (cell.natural_energy),
                           reverse=True)
        for energyTarget in energyTargets:
            if self.CanUpgrade(energyTarget):
                self.Upgrade(energyTarget)

    def UpgradeGold(self, level):
        goldTargets = [
            self.GetCell(e) for e in self.data["own"]["gold"][level - 1]
        ]
        goldTargets.sort(key=lambda cell: (cell.natural_energy), reverse=True)
        for goldTarget in goldTargets:
            if self.CanUpgrade(goldTarget):
                self.Upgrade(goldTarget)

    def Stark(self):
        data = ""
        while not data == "endgame":
            data = input()
            if data == "hold":
                self.hold = True
                print("Holding Game State.")
                print("")
            elif data == "attack":
                self.hold = False
                print("Attack Mode Activated.")
                print("")
            elif data == "defend":
                if len(self.data["edges"]) > 0:
                    self.defenseEnergy = int(
                        int(self.me.energy_source / 2) /
                        len(self.data["edges"]))
                else:
                    self.defenseEnergy = 1
                print("Defense Mode Activated.")
                print("")
            elif data == "recharge":
                self.rechargeNow = True
                self.energyChance = 1000
                print("Recharge Mode Activated.")
                print("")
            elif data == "normal":
                self.rechargeNow = False
                self.energyChance = 2
                print("Recharge Mode Deactivated.")
                print("")
            else:
                data = data.split()
                if data[0] == "d":
                    print("Set defense energy to: " + data[1])
                    self.defenseEnergy = int(data[1])
                elif data[0] == "a":
                    print("Set attack energy to: " + data[1])
                    self.attackEnergy = int(data[1])
                elif data[0] == "r":
                    print("Set attack energy to: " + data[1])
                    self.energyChance = int(data[1])

    def Armor(self):
        for edge in self.data["edges"]:
            edge = self.GetCell(edge)
            if self.me.energy >= 1:
                self.Attack(edge, self.defenseEnergy)

    def Loot(self):
        for i in (2, 1, 0):
            if len(self.data["adjacent"]["enemy"]["gold"][i]) > 0:
                goldTargets = [
                    self.GetCell(b)
                    for b in self.data["adjacent"]["enemy"]["gold"][i]
                ]
                goldTargets.sort(key=lambda cell: (cell.attack_cost))
                for goldTarget in goldTargets:
                    if goldTarget.attack_cost <= self.me.energy:
                        self.Attack(goldTarget)

    def Recharge(self):
        for i in (2, 1, 0):
            if len(self.data["adjacent"]["enemy"]["energy"][i]) > 0:
                goldTargets = [
                    self.GetCell(b)
                    for b in self.data["adjacent"]["enemy"]["energy"][i]
                ]
                goldTargets.sort(key=lambda cell: (cell.attack_cost))
                for goldTarget in goldTargets:
                    if goldTarget.attack_cost <= self.me.energy:
                        self.Attack(goldTarget)

    def Dominate(self):
        targets = [self.GetCell(t) for t in self.data["adjacent"]["empty"]]
        targets.sort(key=lambda cell: (cell.attack_cost))
        for target in targets:
            if target.attack_cost <= self.me.energy:
                self.Attack(target)
        targets = [self.GetCell(t) for t in self.data["adjacent"]["all"]]
        targets.sort(key=lambda cell: (cell.attack_cost))
        for target in targets:
            if target.attack_cost <= self.me.energy:
                self.Attack(target)

    def Snap(self):
        for i in (2, 1, 0):
            if len(self.data["adjacent"]["enemy"]["bases"][i]) > 0:
                bases = [
                    self.GetCell(b)
                    for b in self.data["adjacent"]["enemy"]["bases"][i]
                ]
                for base in bases:
                    snapCost = self.CanSnap(base)
                    if not snapCost == -1:
                        self.Attack(base, snapCost)

    def AllSpark(self):
        if not self.hold:
            if random.choice(range(self.energyChance)) == 0:
                self.UpgradeGold(1)
                self.UpgradeGold(2)
                self.BuildGold()
            else:
                self.UpgradeEnergy(1)
                self.UpgradeEnergy(2)
                self.BuildEnergy()
        else:
            if self.rechargeNow:
                self.UpgradeEnergy(1)
                self.UpgradeEnergy(2)
                self.BuildEnergy()
        self.Snap()
        self.Armor()
        if not self.hold:
            order = random.choice((0, 1, 2))
            if order == 0:
                self.Dominate()
                if random.choice((0, 1)) == 0:
                    self.Recharge()
                    self.Loot()
                else:
                    self.Loot()
                    self.Recharge()
            elif order == 1:
                self.Recharge()
                self.Dominate()
                self.Loot()
            elif order == 2:
                self.Loot()
                self.Dominate()
                self.Recharge()

    def GameLoop(self):
        #print( str( len( self.data[ "edges" ] ) ) )
        #print( str( len( self.data[ "adjacent" ][ "empty" ] ) ) )
        self.Defend()
        if self.tech == 1:
            self.Expand()
        elif self.tech == 2 and not self.rechargeNow:
            self.Bread()
        else:
            self.AllSpark()
Exemplo n.º 12
0
from User2 import User2
from move import move
import numpy as np
from classify import Classification

#DONT FORGET TO IMPORT THINGS

# Create a Colorfight Instance.
global game
game = Colorfight()

# Connect to the server. This will connect to the public room.
game.connect(room='public1')

# game.register should return True if succeed.
if game.register(username = '******', \
                 password = '******'):

    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []

        # Check if you exist in the game. If not, wait for the next round.
        me = game.me

        if game.me == None:
            continue

        #make a move
Exemplo n.º 13
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS

g = Colorfight()
g.connect(room='public1')

if g.register(username='******' + str(random.randrange(0, 100)),
              password='******'):

    while True:
        cmd_list = []

        #offense
        my_attack_list = []
        my_adj_list = []

        #defense
        my_perimeter_list = []

        #collection
        my_upgrade_list = []

        #update game
        g.update_turn()

        if g.me == None:  #execution keeps going into this
            continue

        #shorthands
Exemplo n.º 14
0
        print(test)
        print(test2)


def findHome(game):
    for cell in game.me.cells.values():
        c = game.game_map[cell.position]
        if c.is_home:
            return c


if __name__ == "__main__":
    game = Colorfight()
    game.connect(room='Hi')
    print("STARTING PROGRAM")
    game.update_turn()

    if game.register(username='******',
                     password="******",
                     join_key="testing123"):
        game.update_turn()
        me = game.me
        home = findHome(game)

        myai = AI(game, home, me)

        while True:
            game.update_turn()
            print("working")
            myai.behave()
Exemplo n.º 15
0
        if(g<3 and e <3):
            return BLD_FORTRESS
        if(g>(e+2)):
            return BLD_GOLD_MINE
        else:
            return BLD_ENERGY_WELL
    else:
        print("endgame")
        if(g<3 and e <3):
            return BLD_FORTRESS
        if(g>(e-2)):
            return BLD_GOLD_MINE
        else:
            return BLD_ENERGY_WELL

if game.register(username = '******' , \
        password = "******"):
    # This is the game loop



    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()
Exemplo n.º 16
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS, BUILDING_COST

game = Colorfight()

# Connect to the server. Designate argument for the room
game.connect(room='Musikverein')

# game.register should return True if succeed.
# input relevant username and pw
if game.register(username="******", password="******"):

    # Determines the growth of the colony
    # Increments by one every X number of rounds for which no command is executed
    scaling_factor = 100

    # Counts number of turns where no commands were executed
    no_growth = 0

    # number of turns spent scaling
    growth_turn_ceiling = 200

    # number of cells spent scaling
    growth_cell_ceiling = 300

    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
Exemplo n.º 17
0
# with.
global game
game = Colorfight()

# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room = 'groupb')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change 
# between runs so you can continue the game if disconnected.
if game.register(username = '******', \
		password = '******'):
	# This is the game loop
	while True:
		# The command list we will send to the server
		cmd_list = []
		# The list of cells that we want to attack
		my_attack_list = []
		# update_turn() is required to get the latest information from the
		# server. This will halt the program until it receives the updated
		# information. 
		# After update_turn(), game object will be updated.   
		game.update_turn()


		# Check if you exist in the game. If not, wait for the next round.
		# You may not appear immediately after you join. But you should be 
Exemplo n.º 18
0
                         (home.position.y - c.position.y)**2)
        if c.owner == game.uid and c not in lst and c.building.is_empty == True:
            lst.append([c.position, dist])
    lst.sort(key=lambda x: x[1])
    return lst[0]


def findHome(game):
    for cell in game.me.cells.values():
        c = game.game_map[cell.position]
        if c.is_home:
            return c


if game.register(username='******' + str(random.randint(1, 100)),
                 password=str(int(time.time())),
                 join_key="testing123"):
    # This is the game loop
    numGold = 0
    numEn = 0
    game.update_turn()

    while True:
        game.update_turn()
        me = game.me
        home = None
        for cell in game.me.cells.values():
            c = game.game_map[cell.position]
            if c.is_home:
                home = c
Exemplo n.º 19
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS, BLD_HOME
from AI import AI
game = Colorfight()

game.connect(room = 'public')

if game.register(username = '******', password = "******"):
    # This is the game loop

    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
        # in the game after one round.
        if game.me == None:
            continue

        me = game.me
Exemplo n.º 20
0
            return BLD_GOLD_MINE
            print("f**k")
        if (g > (e - 2)):
            return BLD_GOLD_MINE
        else:
            return BLD_ENERGY_WELL
    else:
        print("endgame")
        if (g < 3 and e < 3):
            return BLD_GOLD_MINE
        if (g > (e - 4)):
            return BLD_GOLD_MINE
        else:
            return BLD_ENERGY_WELL

if game.register(username = '******' , \
        password = "******"):
    # This is the game loop

    while True:

        if game.turn < 60:

            # The command list we will send to the server
            cmd_list = []
            # The list of cells that we want to attack
            my_attack_list = []
            # update_turn() is required to get the latest information from the
            # server. This will halt the program until it receives the updated
            # information.
            # After update_turn(), game object will be updated.
            game.update_turn()
Exemplo n.º 21
0
TOP = 1
LEFT = 2
BOTTOM = 3
RIGHT = 4

MIN_ENERGY = 500
side = 1 
ring = 1
is_first_move = True
continue_moving = True
ring_finished = False
is_stopping = False
moved_this_side = 0
game.connect(room = 'public1')

if game.register(username = '******', \
        password = '******'):
    while True:
        cmd_list = []
        my_attack_list = []
        game.update_turn()
        if game.me == None:
            continue
        me = game.me

        while True:

            if is_first_move:
                print(len(game.me.cells))
                for cell in game.me.cells.values():
                    home = cell.position
                    print("home: ", home.x, home.y)
Exemplo n.º 22
0
# Create a Colorfight Instance. This will be the object that you interact
# with.
game = Colorfight()

# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room = 'public1')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change 
# between runs so you can continue the game if disconnected.
if game.register(username = '******' + str(random.randint(1, 100)), \
        password = str(int(time.time()))):
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information. 
        # After update_turn(), game object will be updated.   
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be 
        # in the game after one round.
Exemplo n.º 23
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS, BLD_HOME

game = Colorfight()

game.connect(room='test_room2')

if game.register(username='******', password="******"):
    # This is the game loop

    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
        # in the game after one round.
        if game.me == None:
            continue

        me = game.me
        # find the best cells to attack
Exemplo n.º 24
0
# with.
global game
game = Colorfight()

# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room='smallpublic')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change
# between runs so you can continue the game if disconnected.
if game.register(username = '******', \
  password = '******'):
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
        # in the game after one round.
Exemplo n.º 25
0
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS, BLD_HOME

game = Colorfight()

game.connect(room = 'public')

mode = 'expansion'

def formation():
    if mode == 'defense' and cell.owner == me.uid and cell.building.is_empty and me.gold >= 100:
        building = random.choice([BLD_FORTRESS, BLD_FORTRESS, BLD_FORTRESS, BLD_FORTRESS, BLD_GOLD_MINE, BLD_ENERGY_WELL])
        cmd_list.append(game.build(cell.position, building))
        print("We build {} on ({}, {})".format(building, cell.position.x, cell.position.y))
        me.gold -= 100

if game.register(username = '******', password = "******"):
    # This is the game loop

    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # update_turn() is required to get the latest information from the
        # server. This will halt the program until it receives the updated
        # information.
        # After update_turn(), game object will be updated.
        game.update_turn()

        # Check if you exist in the game. If not, wait for the next round.
        # You may not appear immediately after you join. But you should be
Exemplo n.º 26
0
    for attackcell in potential:
        if attackcell[0].attack_cost < me.energy:
            cmd_list.append(
                game.attack(attackcell[0].position, attackcell[0].attack_cost))
            # print("We are attacking ({}, {}) with {} energy".format(
            #   attackcell[0].position.x, attackcell[0].position.y, attackcell[0].attack_cost))
            game.me.energy -= attackcell[0].attack_cost


game = Colorfight()

game.connect(room='Hi')

if game.register(username='******' + str(random.randint(1, 100)),
                 password=str(int(time.time())),
                 join_key="testing123"):
    # This is the game loop
    numEn = 0
    numGold = 0
    numFort = 0

    while True:

        cmd_list = []

        my_attack_list = []

        game.update_turn()

        if game.me == None:
Exemplo n.º 27
0
    else:
        return None


# Connect to the server. This will connect to the public room. If you want to
# join other rooms, you need to change the argument
game.connect(room='public2')

# game.register should return True if succeed.
# As no duplicate usernames are allowed, a random integer string is appended
# to the example username. You don't need to do this, change the username
# to your ID.
# You need to set a password. For the example AI, the current time is used
# as the password. You should change it to something that will not change
# between runs so you can continue the game if disconnected.
if game.register(username = '******', \
  password = str(int(time.time()))):
    # This is the game loop
    while True:
        # The command list we will send to the server
        cmd_list = []
        # The list of cells that we want to attack
        my_attack_list = []
        # waits for updated game state from server
        game.update_turn()

        # create your ai in the game
        if game.me == None:
            continue
        me = game.me

        home_cell = find_home_cell()
Exemplo n.º 28
0
class Inevitable:
    def __init__(self):
        self.game = Colorfight()
        pass

    def Start(self):
        self.game.connect(room='public')
        if self.game.register(username='******', password="******"):
            while True:
                if self.Refresh():
                    self.FetchInfo()
                    self.GameLoop()
                    self.Send()

    def GetCell(self, pos):
        return self.game.game_map[pos]

    def Attack(self, cell, energy=None):
        if energy == None:
            energy = cell.attack_cost
        self.me.energy -= energy
        self.cmdList.append(self.game.attack(cell.position, energy))
        self.attackList.append(cell.position)

    def Upgrade(self, cell):
        cellType = cell.building.name
        cellLevel = cell.building.level
        if cellType == "home":
            if cellLevel == 1:
                self.me.energy -= HOME_I[0]
                self.me.gold -= HOME_I[1]
            elif cellLevel == 2:
                self.me.energy -= HOME_II[0]
                self.me.gold -= HOME_II[1]
        elif cellType == "energy_well":
            if cellLevel == 1:
                self.me.energy -= ENERGY_I[0]
                self.me.gold -= ENERGY_I[1]
            elif cellLevel == 2:
                self.me.energy -= ENERGY_II[0]
                self.me.gold -= ENERGY_II[1]
        elif cellType == "gold_mine":
            if cellLevel == 1:
                self.me.energy -= GOLD_I[0]
                self.me.gold -= GOLD_I[1]
            elif cellLevel == 2:
                self.me.energy -= GOLD_II[0]
                self.me.gold -= GOLD_II[1]
        elif cellType == "fortress":
            if cellLevel == 1:
                self.me.energy -= FORTRESS_I[0]
                self.me.gold -= FORTRESS_I[1]
            elif cellLevel == 2:
                self.me.energy -= FORTRESS_II[0]
                self.me.gold -= FORTRESS_II[1]
        self.cmdList.append(self.game.upgrade(cell.position))

    def CanBuild(self, building):
        if building == BLD_ENERGY_WELL:
            return self.me.energy >= ENERGY_I[0] and self.me.gold >= ENERGY_I[1]
        elif building == BLD_GOLD_MINE:
            return self.me.energy >= GOLD_I[0] and self.me.gold >= GOLD_I[1]
        elif building == BLD_FORTRESS:
            return self.me.energy >= FORTRESS_I[
                0] and self.me.gold >= FORTRESS_I[1]

    def CanUpgrade(self, cell):
        cellType = cell.building.name
        cellLevel = cell.building.level
        if cellType == "home":
            if cellLevel == 1:
                return self.me.energy >= HOME_I[0] and self.me.gold >= HOME_I[1]
            elif cellLevel == 2:
                return self.me.energy >= HOME_II[
                    0] and self.me.gold >= HOME_II[1]
            else:
                return False
        elif cellType == "energy_well":
            if cellLevel == 1:
                return self.me.energy >= ENERGY_I[
                    0] and self.me.gold >= ENERGY_I[1]
            elif cellLevel == 2:
                return self.me.energy >= ENERGY_II[
                    0] and self.me.gold >= ENERGY_II[1]
            else:
                return False
        elif cellType == "gold_mine":
            if cellLevel == 1:
                return self.me.energy >= GOLD_I[0] and self.me.gold >= GOLD_I[1]
            elif cellLevel == 2:
                return self.me.energy >= GOLD_II[
                    0] and self.me.gold >= GOLD_II[1]
            else:
                return False
        elif cellType == "fortress":
            if cellLevel == 1:
                return self.me.energy >= FORTRESS_I[
                    0] and self.me.gold >= FORTRESS_I[1]
            elif cellLevel == 2:
                return self.me.energy >= FORTRESS_II[
                    0] and self.me.gold >= FORTRESS_II[1]
            else:
                return False

    def Build(self, cell, building):
        if building == BLD_ENERGY_WELL:
            self.me.energy -= ENERGY_I[0]
            self.me.gold -= ENERGY_I[1]
        elif building == BLD_GOLD_MINE:
            self.me.energy -= GOLD_I[0]
            self.me.gold -= GOLD_I[1]
        elif building == BLD_FORTRESS:
            self.me.energy -= FORTRESS_I[0]
            self.me.gold -= FORTRESS_I[1]
        self.cmdList.append(self.game.build(cell.position, building))

    def FetchAdjacent(self, cell):
        return [
            self.game.game_map[pos]
            for pos in cell.position.get_surrounding_cardinals()
        ]

    def Empty(self, cell):
        return cell.owner == 0

    def Own(self, cell):
        return cell.owner == self.game.uid

    def Enemy(self, cell):
        return not (cell.owner == 0 or not cell.owner == self.game.uid)

    def FetchInfo(self):
        self.me = self.game.me
        self.mode = 0
        self.tech = 0

        self.data = {}

        self.data["adjacent"] = {}
        self.data["adjacent"]["all"] = set()
        self.data["adjacent"]["empty"] = set()
        self.data["adjacent"]["enemy"] = {}
        self.data["adjacent"]["enemy"]["all"] = set()
        self.data["adjacent"]["enemy"]["empty"] = set()
        self.data["adjacent"]["enemy"]["energy"] = [set(), set(), set()]
        self.data["adjacent"]["enemy"]["gold"] = [set(), set(), set()]
        self.data["adjacent"]["enemy"]["bases"] = [set(), set(), set()]
        self.data["adjacent"]["enemy"]["forts"] = [set(), set(), set()]

        self.data["own"] = {}
        self.data["own"]["all"] = set()
        self.data["own"]["empty"] = set()
        self.data["own"]["energy"] = [set(), set(), set()]
        self.data["own"]["gold"] = [set(), set(), set()]
        self.data["own"]["bases"] = [set(), set(), set()]
        self.data["own"]["forts"] = [set(), set(), set()]

        self.data["enemy"] = {}
        self.data["enemy"]["all"] = set()
        self.data["enemy"]["empty"] = set()
        self.data["enemy"]["energy"] = [set(), set(), set()]
        self.data["enemy"]["gold"] = [set(), set(), set()]
        self.data["enemy"]["bases"] = [set(), set(), set()]
        self.data["enemy"]["forts"] = [set(), set(), set()]

        self.cmdList = []
        self.attackList = []

        for x in range(30):
            for y in range(30):
                pos = Position(x, y)
                cell = self.GetCell(pos)
                if self.Own(cell):
                    self.data["own"]["all"].add(pos)
                    cellType = cell.building.name
                    if cellType == "empty":
                        self.data["own"]["empty"].add(pos)
                    elif cellType == "home":
                        self.data["own"]["bases"][cell.building.level -
                                                  1].add(pos)
                    elif cellType == "energy_well":
                        self.data["own"]["energy"][cell.building.level -
                                                   1].add(pos)
                    elif cellType == "gold_mine":
                        self.data["own"]["gold"][cell.building.level -
                                                 1].add(pos)
                    elif cellType == "fortress":
                        self.data["own"]["forts"][cell.building.level -
                                                  1].add(pos)
                    for adj in self.FetchAdjacent(cell):
                        if not self.Own(adj):
                            self.data["adjacent"]["all"].add(adj.position)
                            if self.Enemy(adj):
                                self.data["adjacent"]["enemy"]["all"].add(
                                    adj.position)
                                adjType = adj.building.name
                                if adjType == "empty":
                                    self.data["own"]["empty"].add(adj.position)
                                elif adjType == "home":
                                    self.data["own"]["bases"][
                                        adj.building.level - 1].add(
                                            adj.position)
                                elif adjType == "energy_well":
                                    self.data["own"]["energy"][
                                        adj.building.level - 1].add(
                                            adj.position)
                                elif adjType == "gold_mine":
                                    self.data["own"]["gold"][adj.building.level
                                                             - 1].add(
                                                                 adj.position)
                                elif adjType == "fortress":
                                    self.data["own"]["forts"][
                                        adj.building.level - 1].add(
                                            adj.position)
                            else:
                                self.data["adjacent"]["empty"].add(
                                    adj.position)

    def Refresh(self):
        self.game.update_turn()
        return not self.game.me == None

    def Send(self):
        self.game.send_cmd(self.cmdList)

    def Defend(self):
        base = None
        if len(self.data["own"]["bases"][0]) > 0:
            base = self.GetCell(list(self.data["own"]["bases"][0])[0])
        if len(self.data["own"]["bases"][1]) > 0:
            base = self.GetCell(list(self.data["own"]["bases"][1])[0])
        if len(self.data["own"]["bases"][2]) > 0:
            base = self.GetCell(list(self.data["own"]["bases"][2])[0])
        if base:
            self.tech = base.building.level
            if self.CanUpgrade(base):
                self.Upgrade(base)

    def Expand(self):
        if self.me.gold <= 500:
            self.BuildEnergy()
        targets = [self.GetCell(t) for t in self.data["adjacent"]["empty"]]
        targets.sort(key=lambda cell: (cell.natural_energy, -cell.attack_cost),
                     reverse=True)
        for target in targets:
            if target.attack_cost <= self.me.energy:
                self.Attack(target)

    def Loot(self):
        self.BuildGold()
        targets = [self.GetCell(t) for t in self.data["adjacent"]["empty"]]
        targets.sort(key=lambda cell: (cell.natural_gold, -cell.attack_cost),
                     reverse=True)
        for target in targets:
            if target.attack_cost <= self.me.energy:
                self.Attack(target)

    def BuildEnergy(self):
        energyTargets = [self.GetCell(e) for e in self.data["own"]["empty"]]
        energyTargets.sort(key=lambda cell: (cell.natural_energy),
                           reverse=True)
        for energyTarget in energyTargets:
            if self.CanBuild(BLD_ENERGY_WELL):
                self.Build(energyTarget, BLD_ENERGY_WELL)

    def BuildGold(self):
        goldTargets = [self.GetCell(e) for e in self.data["own"]["empty"]]
        goldTargets.sort(key=lambda cell: (cell.natural_gold), reverse=True)
        for goldTarget in goldTargets:
            if self.CanBuild(BLD_GOLD_MINE):
                self.Build(goldTarget, BLD_GOLD_MINE)

    def UpgradeEnergy(self, level):
        energyTargets = [
            self.GetCell(e) for e in self.data["own"]["energy"][level - 1]
        ]
        energyTargets.sort(key=lambda cell: (cell.natural_energy),
                           reverse=True)
        for energyTarget in energyTargets:
            if self.CanUpgrade(energyTarget):
                self.Upgrade(energyTarget)

    def UpgradeGold(self, level):
        goldTargets = [
            self.GetCell(e) for e in self.data["own"]["gold"][level - 1]
        ]
        goldTargets.sort(key=lambda cell: (cell.natural_energy), reverse=True)
        for goldTarget in goldTargets:
            if self.CanUpgrade(goldTarget):
                self.Upgrade(goldTarget)

    def Snap(self):
        if len(self.data["adjacent"]):
            pass

    def AllSpark(self):
        if random.choice((0, 1)) == 0:
            self.UpgradeEnergy(1)
            self.UpgradeEnergy(2)
            self.BuildEnergy()
        else:
            self.UpgradeGold(1)
            self.UpgradeGold(2)
            self.BuildGold()
        targets = [self.GetCell(t) for t in self.data["adjacent"]["all"]]
        targets.sort(key=lambda cell: (cell.attack_cost))
        for target in targets:
            if target.attack_cost <= self.me.energy:
                self.Attack(target)

    def GameLoop(self):
        print("Energy Source: " +
              str(self.me.energy_source - self.me.tax_amount))
        print("Energy Source: " +
              str(self.me.gold_source - self.me.tax_amount))
        print("")
        self.Defend()
        if self.tech == 1:
            self.Expand()
        elif self.tech == 2:
            self.Loot()
        else:
            self.AllSpark()
Exemplo n.º 29
0
from colorfight import Colorfight
import time
import random
from colorfight.constants import BLD_GOLD_MINE, BLD_ENERGY_WELL, BLD_FORTRESS

# Create a Colorfight Instance. This will be the object that you interact
# with.
gamers = []
for gamer_id in range(8):
    
    game = Colorfight()
    game.connect(room = 'public')
    game.register(username = '******' + gamer_id, password = '******')
    gamers.append(game)

    # This is the game loop
while True:

    for game in gamers:
        game.update_turn()

        cmd_list = []
        my_attack_list = []

        if game.me == None:
            continue

        me = game.me
        my_energy = me.energy

        for cell in game.me.cells.values():