Ejemplo n.º 1
0
def start_commanding(session_id, block_size, config_path):

    print_headline("Connect to a server")
    print("You will have to connect to a NEAT Server.")
    server_address = "127.0.0.1"
    server_port = 8081
    display_choice(
        [
            "IP Address: " + server_address,
            "Port: " + str(server_port),
            "Connect"
        ]
    )
    edit_index = int(
        get_input(
            "Choose an entry to edit"
        )
    )
    if edit_index == 1:
        server_address = edit_string(server_address)
    elif edit_index == 2:
        server_port = int(edit_string(str(server_port)))
    elif edit_index == 3:
        client = SimulationClient(server_address, server_port)

        try:
            client.announce_session(
                session_id,
                config_path,
                block_size
            )
        except NetworkProtocolException as e:
            print(e)
            return
Ejemplo n.º 2
0
from NEAT.Networking.Client.SimulationClient import SimulationClient

cli = SimulationClient("127.0.0.1", 8081)

print(">> Announcing session...")
cli.announce_session(
    "testSession9",
    "./NEAT/Config",
    1
)

for generation_number in range(10):

    print("\n\n###: Generation number:", generation_number)

    for i in range(10):

        print("\nNext Block! ", i)

        print(">> Getting block...")
        block = cli.get_block(i)
        print(">> Got block: ", block)

        for genome, inputs in block.items():
            for input in inputs:
                block[genome][input] = 0.5

        print(">> Setting inputs...")
        cli.set_block_inputs(block, i)

        print(">> Getting outputs...")