Esempio n. 1
0
 def createStupidAnimat(self, x, y):
     f = open('neuro.net', 'r')
     trained_net = pickle.load(f)
     learner = ENAC()
     learner._setLearningRate(0.03)
     brain = BrainController(trained_net)
     new_x = x + random.randint(-3, 3)
     if new_x > 79:
         new_x = 79
     elif new_x < 0:
         new_x = 0
     new_y = y + random.randint(-3, 3)
     if new_y > 79:
         new_y = 79
     elif new_y < 0:
         new_y = 0
     sa = StupidAnimat(new_x, new_y, brain, learner, self)
     sa.brain.validate_net()
     world = World(self)
     task = InteractTask(world, sa)
     self.stupid_animats.append(sa)
     self.tasks.append(task)
Esempio n. 2
0
import pickle
import time

# Create environment
sub_env = Environment(20, 20)
world = World(sub_env)

# Brain for the animat, we have already trained the data
f = open('neuro.net', 'r')
trained_net = pickle.load(f)
brain = BrainController(trained_net)

# Learning method we use
#learner = PolicyGradientLearner()
learner = ENAC()
learner._setLearningRate(0.2)
# Create an animat
animat = StupidAnimat(trained_net, learner, sub_env)

# Establish a task
task = InteractTask(world, animat)

brain.validate_net()
experiment = Experiment(task, animat)
while True:
    experiment.doInteractions(10000)
    animat.learn()
    animat.reset()
    brain.validate_net()
    time.sleep(3)