sys.exit(1)
    c = Client(torcs_path=sys.argv[1])

    # CONFIGURATION #
    POPULATION_SIZE = 10
    BATCHES = 5
    EVO_ITERATIONS = 3
    TRACK = 'random'
    LAPS = 2
    NORMALIZED_FITNESS = True
    c.timeout = LAPS * 500
    c.auto_recover = True
    #################

    trained_pop = []
    trained_pop.append(NetworkDriver.from_directory(trained_files.get_file("Human")))
    trained_pop.append(NetworkDriver.from_directory(trained_files.get_file("SimpleDriver")))
    trained_pop.append(NetworkDriver.from_directory(trained_files.get_file("SimpleExample2")))
    trained_pop.append(NetworkDriver.from_directory(trained_files.get_file("bot1")))
    trained_pop.append(NetworkDriver.from_directory(trained_files.get_file("bot2")))

    evo = Evolution(torcs_client=c)
    global_population_fitness_history = []
    global_tracks = []
    start = timeit.default_timer()
    pop = list(trained_pop)
    while len(pop) < POPULATION_SIZE:
        new_driver = random.choice(trained_pop).mutate()
        pop.append(new_driver)
    evo.laps = LAPS
    evo.track = TRACK
                # print "distance raced:", s['distRaced']
                return driver.compute_fitness(last_sensor=s, lap_times=lap_times, max_speed=max_speed,
                                              average_speed=avg_speed.avg, timeout_reached=timeout_reached)
            else:
                return 0.0
        except KeyboardInterrupt:
            print "Exit client"
        except Exception as e:
            print "Client Error:", e
        finally:
            #print "race call took %0.1f seconds." % (timeit.default_timer() - start_time)
            self.close()


if __name__ == '__main__':
    if len(sys.argv) < 2:
        print "Usage: python client.py torcs_install_path"
        sys.exit(1)

    ndr = NetworkDriver.from_directory(trained_files.get_file("mlp_single_layer"))
    # ndr = NetworkDriver.from_file(trained_files.get_file("best_evo_driver_01.pkl"))

    #c = Client(torcs_path=sys.argv[1])
    #c.configure(track_name='g-track-2', laps=2)
    c = Client(torcs_path=None)  # Use this for GUI test

    c.timeout = 1200
    c.auto_recover = False
    c.race(driver=ndr)
    print "fitness:", ndr.fitness