Example #1
0
    parser.add_option("-f", "--fullscreen", dest="fullscreen", default=False,
            action="store_true", help="Show in fullscreen")
    parser.add_option("-s", "--sound", dest="sound", default=False,
            action="store_true", help="Play sound")

    (options, args) = parser.parse_args()

    if len(args) == 0:
        readfile = sys.stdin
    else:
        readfile = args[0]

    options.index = int(options.index)

    # Load springbot
    springbot = load_xml(readfile, limit=options.index+1)[options.index]

    pygame.init()
    pygame.display.set_mode((WIDTH,HEIGHT),
            pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE if options.fullscreen else pygame.DOUBLEBUF)
    pygame.display.set_caption('Springbots viewer')
    pygame.mouse.set_visible(not options.fullscreen)

    if options.sound:
        colide_snd = pygame.mixer.Sound(os.path.join('sound','pop.wav'))

    # Center springbot horizontaly and touches ground
    if not options.liquid:
        springbot.centerGround(HEIGHT)
    else:
        for node in springbot.nodes:
Example #2
0
    options.save_freq = int(options.save_freq)
    options.limit = int(options.limit)
    options.start_at = int(options.start_at)

    options.prefix = options.prefix if options.prefix is not None else lower(latimname(3))
    if options.verbose:
        print "# %s experiment." % options.prefix

    if len(args) == 0:
        readfile = sys.stdin
    else:
        readfile = args[0]

    # Reads the initial population
    init_population = load_xml(readfile)

    # If graphics is enabled, starts pygame
    if options.graphics:
        pygame.init()
        pygame.display.set_mode(
            (WIDTH, HEIGHT),
            pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE if options.fullscreen else pygame.DOUBLEBUF,
        )
        pygame.display.set_caption("Evolving springbot for %s" % (options.fitness))
        pygame.mouse.set_visible(not options.fullscreen)

    # Starts the simulation
    serial_evolve(
        init_population,
        fitness,
Example #3
0
    options.number = int(options.number)
    options.row = int(options.row)

    if len(args) == 0:
        readfile = sys.stdin
        writefile = sys.stdout
    elif len(args) == 1:
        readfile = args[0]
        writefile = sys.stdout
    else:
        readfile = args[0]
        writefile = open(args[1], 'w')

    # Load springbots
    springbots = load_xml(readfile, limit=options.number)

    # Write xml header
    writefile.write(\
"""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg  version="1.1" xmlns="http://www.w3.org/2000/svg">
""")

    x_offset = 0
    y_offset = 0

    for c, springbot in enumerate(springbots):

        if c != 0 and c % options.row == 0:
Example #4
0
        metavar="PREFIX")
    (options, args) = parser.parse_args()

    # Read command line parameters
    serverslist = options.serverslist
    fitness_function = options.fitness

    options.save_freq = int(options.save_freq)
    options.limit = int(options.limit)
    options.start_at = int(options.start_at)

    options.prefix = options.prefix if options.prefix is not None else lower(
        latimname(3))
    if options.verbose: print("# %s experiment." % options.prefix)

    if len(args) == 0:
        readfile = sys.stdin
    else:
        readfile = args[0]

    # Reads the initial population
    population = load_xml(readfile)

    # Starts the simulation
    network_evolve(save_freq=options.save_freq,
                   limit=options.limit,
                   verbose=options.verbose,
                   best=options.best,
                   start_iteration=options.start_at,
                   prefix=options.prefix)