from Animat.QLearn import QLearn
import time
from numpy import zeros
import random
#import matplotlib.pyplot as plt
#import matplotlib.animation as animation

print 'Running Simulation - have q learner give us an action to take'

#Init Environment and food sources
env = Env(50)
env.makeGradient()
for i in range (0,10):
	env.makeFoodRandom()
	#env.makeFood(20,20);
env.updateMap()

#Create Animat
#a = Animat(0,0,env, filename)

# This should really be inside the animat class, since that's the one that'll make
# a decision on what action to take.


actions = ['north','south','east','west','stay','eat','pickup','drop'];
#state = getState();


for i in range(0,300):
	env.tick()
	#a.tick()
Beispiel #2
0
import random
import matplotlib.pyplot as plt
import matplotlib.animation as animation

print 'Running Simulation - Moving food around, picking up, dropping'

# Deprecated
filename = 'nn_precise_100k.p'

size = 50;
env1 = Env(size,0)
env2 = Env(size,1);
for i in range (0,20):
	env1.makeFoodRandom();
	env2.makeFoodRandom();
env1.updateMap()
env2.updateMap()

animats = [Animat(25,25,[env1,env2],filename),Animat(10,40,[env1,env2],filename)];

stateMachine = ['notholding','notholding'];

fig = plt.figure()
ims = []

toEat = [random.randrange(0,2),random.randrange(0,2)];
toFollow = [0 if toEat == 1 else 1,0 if toEat == 1 else 1];
for i in range(0,1000):
	env1.tick()
	env2.tick()
	for index,a in enumerate(animats):
Beispiel #3
0
import time
from numpy import zeros
import random
import matplotlib.pyplot as plt
import matplotlib.animation as animation

print 'Running Simulation - Find food'

#filename = 'nn_scents_based.p'
filename = 'nn_precise_100k.p'
#Init Environment and food sources
env = Env(50)
for i in range(0, 10):
    env.makeFoodRandom()
    #env.makeFood(20,20);
env.updateMap()

#Create Animat
ID = 1
a = Animat(0, 0, env, filename, 1)

fig = plt.figure()
ims = []
for i in range(0, 1000):
    print "Tick: " + str(i)
    env.tick()
    if a.alive:
        a.tickStateMachine()
    env.map[a.y, a.x] = env.map.max()
    im = plt.imshow(env.map)
    im.set_cmap('spectral')
import matplotlib
matplotlib.use('TKAgg')
import sys
sys.path.append("..")

from Environment.Env import Env
from Animat.Animat import Animat
import time
from numpy import zeros
import random
import matplotlib.pyplot as plt
import matplotlib.animation as animation

print 'Running Simulation 3 - Gradient maker'
mapSize = 100
food = Env(mapSize)
#a = Animat.randomStart(mapSize,mapSize)
food.makeGradient()
print 'Made gradient.'

for count in range(0,20):
	food.makeFoodRandom()

print str(count)+' food made.'
food.updateMap();

fig2 = plt.figure()
plt.pcolor(food.map)
plt.ion()
plt.show()
Beispiel #5
0
matplotlib.use('TKAgg')
import sys

sys.path.append("..")

from Environment.Env import Env
from Animat.Animat import Animat
import time
from numpy import zeros
import random
import matplotlib.pyplot as plt
import matplotlib.animation as animation

print 'Running Simulation 3 - Gradient maker'
mapSize = 100
food = Env(mapSize)
#a = Animat.randomStart(mapSize,mapSize)
food.makeGradient()
print 'Made gradient.'

for count in range(0, 20):
    food.makeFoodRandom()

print str(count) + ' food made.'
food.updateMap()

fig2 = plt.figure()
plt.pcolor(food.map)
plt.ion()
plt.show()