예제 #1
0
import cells
import genes

import cmath
import math
from random import random, randrange

CallForHelpGene = genes.make_normally_perturbed_gene(0.01)
CallOfDutyGene = genes.make_normally_perturbed_gene(0.01)
DraftDodgerGene = genes.make_normally_perturbed_gene(0.01)
SpawnProbabilityGene = genes.make_normally_perturbed_gene(0.01)
SpawnEnergyThresholdGene = genes.make_normally_perturbed_gene(5, 50, 5000)
ColonizeProbabilityGene = genes.make_normally_perturbed_gene(0.01)

CallTypeGene = genes.make_drastic_mutation_gene(0.01)

MODE_NORMAL = 0
MODE_PREP = 5
MODE_ATTACK = 6
MODE_COLONIZE = 7

def fuzz_coord(c):
  return c + randrange(-1,2)


class AgentMind:
  def __init__(self, args):
    self.my_plant = None
    self.mode = MODE_NORMAL
    self.target_range = randrange(50,200)
    if args is None:
#

import cells

from cells import Action
from cells import ACT_SPAWN, ACT_MOVE, ACT_EAT, ACT_RELEASE, ACT_ATTACK
from cells import ACT_LIFT, ACT_DROP

import cmath
from random import choice, random, randrange

import numpy

from genes import InitializerGene, make_normally_perturbed_gene

DesiredEnergyGene = make_normally_perturbed_gene(5, cells.ATTACK_POWER,
                                                 cells.ENERGY_CAP)
FieldSpawnEnergyGene = make_normally_perturbed_gene(5, cells.SPAWN_MIN_ENERGY,
                                                    cells.ENERGY_CAP)
PlantSpawnEnergyGene = make_normally_perturbed_gene(5, cells.SPAWN_MIN_ENERGY,
                                                    cells.ENERGY_CAP)


def debug(s):
    #print s
    pass


class MessageType(object):
    ATTACK = 0

예제 #3
0
import cells
import genes

import cmath
import math
from random import random, randrange

CallForHelpGene = genes.make_normally_perturbed_gene(0.01)
CallOfDutyGene = genes.make_normally_perturbed_gene(0.01)
DraftDodgerGene = genes.make_normally_perturbed_gene(0.01)
SpawnProbabilityGene = genes.make_normally_perturbed_gene(0.01)
SpawnEnergyThresholdGene = genes.make_normally_perturbed_gene(5, 50, 5000)
ColonizeProbabilityGene = genes.make_normally_perturbed_gene(0.01)

CallTypeGene = genes.make_drastic_mutation_gene(0.01)

MODE_NORMAL = 0
MODE_PREP = 5
MODE_ATTACK = 6
MODE_COLONIZE = 7


def fuzz_coord(c):
    return c + randrange(-1, 2)


class AgentMind(object):
    def __init__(self, args):
        self.my_plant = None
        self.mode = MODE_NORMAL
        self.target_range = randrange(50, 200)
예제 #4
0
import cells

from cells import Action
from cells import ACT_SPAWN, ACT_MOVE, ACT_EAT, ACT_RELEASE, ACT_ATTACK
from cells import ACT_LIFT, ACT_DROP

import cmath
from random import choice, random, randrange

import numpy

from genes import InitializerGene, make_normally_perturbed_gene


DesiredEnergyGene = make_normally_perturbed_gene(5, cells.ATTACK_POWER, cells.ENERGY_CAP)
FieldSpawnEnergyGene = make_normally_perturbed_gene(5, cells.SPAWN_MIN_ENERGY, cells.ENERGY_CAP)
PlantSpawnEnergyGene = make_normally_perturbed_gene(5, cells.SPAWN_MIN_ENERGY, cells.ENERGY_CAP)


def debug(s):
    # print s
    pass


class MessageType(object):
    ATTACK = 0


size = 300  # cells.config.getint('terrain', 'bounds')
예제 #5
0
import cells
import genes

import cmath
import math
import random

CallForHelpGene = genes.make_normally_perturbed_gene(0.0)
CallOfDutyGene = genes.make_normally_perturbed_gene(0.0)
DraftDodgerGene = genes.make_normally_perturbed_gene(0.0)

class AgentMind:
    def __init__(self, args):
        self.my_plant = None
        self.mode = 1
        self.target_range = random.randrange(50,200)
        if args is None:
            self.call_for_help = CallForHelpGene(genes.InitializerGene(0.5))
            self.call_of_duty = CallOfDutyGene(genes.InitializerGene(0.5))
            self.draft_dodger = DraftDodgerGene(genes.InitializerGene(0.5))
        else:
            parent = args[0]
            self.call_for_help = parent.call_for_help.spawn()
            self.call_of_duty = parent.call_of_duty.spawn()
            self.draft_dodger = parent.draft_dodger.spawn()

    def act(self,view,msg):
        x_sum = 0
        y_sum = 0
        dir = 1
        n = len(view.get_plants())