Ejemplo n.º 1
0
    redEng.stop()
    return score

# start up the simulation
pyroConfig = Configuration()
pyroConfig.put("pyrobot", "gui", "tk")
redRobot = Engine(robotfile="PyrobotRobot60000.py",
                 simfile="PyrobotSimulator",
                 config=pyroConfig,
                 worldfile="redFlagWorld.py")
blueRobot = Engine(robotfile="PyrobotRobot60001.py")
redEng = redRobot.robot
blueEng = blueRobot.robot

# set up neat
config.load('redEat_config')
chromosome.node_gene_type = genome.NodeGene

def main(argv = None):
    if argv is None:
        argv = sys.argv[1:]
    chromo_file = None
    log_file = None
    if len(argv) == 0:
        pass
    elif len(argv) == 1:
        chromo_gen = argv[0]
        chromo_file = "red_best_chromo_" + chromo_gen
    elif len(argv) == 2:
        chromo_gen = argv[0]
        chromo_file = "red_best_chromo_" + chromo_gen
Ejemplo n.º 2
0
    return score


# start up the simulation
pyroConfig = Configuration()
pyroConfig.put("pyrobot", "gui", "tk")
redRobot = Engine(robotfile="PyrobotRobot60000.py",
                  simfile="PyrobotSimulator",
                  config=pyroConfig,
                  worldfile="redFlagWorld.py")
blueRobot = Engine(robotfile="PyrobotRobot60001.py")
redEng = redRobot.robot
blueEng = blueRobot.robot

# set up neat
config.load('redEat_config')
chromosome.node_gene_type = genome.NodeGene


def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]
    chromo_file = None
    log_file = None
    if len(argv) == 0:
        pass
    elif len(argv) == 1:
        chromo_gen = argv[0]
        chromo_file = "red_best_chromo_" + chromo_gen
    elif len(argv) == 2:
        chromo_gen = argv[0]
Ejemplo n.º 3
0
from pyrobot.engine import Engine
from pyrobot.system.config import *
import time
import os
import sys
import math, random
import cPickle as pickle
from neat import config, population, chromosome, genome, visualize
from neat.nn import nn_pure as nn

config.load('blueEat_config')
chromosome.node_gene_type = genome.NodeGene
pyroConfig = Configuration()
pyroConfig.put("pyrobot", "gui", "tk")
redEng = Engine(robotfile="PyrobotRobot60002.py",
                simfile="PyrobotSimulator",
                config=pyroConfig,
                worldfile="blueFlagWorld.py")
blueEng = Engine(robotfile="PyrobotRobot60003.py")

def eval_fitness(population):
    """
    Evaluate the fitness of the given population.
    """
    print "Evaluating the BLUE robot..."
    for chromo in population:
        chromo.fitness = eval_individual(chromo, population.getGen())
        print "Fitness:", chromo.fitness

def eval_individual(chromo, currentGen, logFP=None):
    if currentGen > 0:
Ejemplo n.º 4
0
from pyrobot.engine import Engine
from pyrobot.system.config import *
import time
import os
import sys
import math, random
import cPickle as pickle
from neat import config, population, chromosome, genome, visualize
from neat.nn import nn_pure as nn

config.load('blueEat_config')
chromosome.node_gene_type = genome.NodeGene
pyroConfig = Configuration()
pyroConfig.put("pyrobot", "gui", "tk")
redEng = Engine(robotfile="PyrobotRobot60002.py",
                simfile="PyrobotSimulator",
                config=pyroConfig,
                worldfile="blueFlagWorld.py")
blueEng = Engine(robotfile="PyrobotRobot60003.py")


def eval_fitness(population):
    """
    Evaluate the fitness of the given population.
    """
    print "Evaluating the BLUE robot..."
    for chromo in population:
        chromo.fitness = eval_individual(chromo, population.getGen())
        print "Fitness:", chromo.fitness