Пример #1
0
from Environment.Env import Env
#from Animat.Animat import Animat
#from Animat.NNInitializer import NNInitializer
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();
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()
Пример #3
0
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 2'
mapSize = 15
food = Env(mapSize)
a = Animat.randomStart(mapSize, mapSize)
food.makeGradient()

for iteration in range(1, 10):
    # Pick a random spot
    foody = random.randrange(0, mapSize)
    foodx = random.randrange(0, mapSize)
    print str(foody) + ' ' + str(foodx)
    food.map[foody, foodx] = 5  # random number

    # pass animat object our map
    # food = a.goToLocation(foody,foodx,food)
    # animat should behave appropriately
    # it should return the map unmodified

    # check to see if the animat did the right thing
Пример #4
0
from Environment.Env import Env
from Animat.Animat import Animat
from Animat.NNInitializer import NNInitializer
import time
from numpy import zeros
import random
import matplotlib.pyplot as plt
import matplotlib.animation as animation

if len(sys.argv) < 2:
    print "Filename required for neural net"
    exit()

print 'Running Animat Simulations'
#Load initial Neural Net
filename = sys.argv[1]

#Init Environment and food sources
env = Env(250)
env.makeGradient()
for i in range(1, 2):
    env.makeFoodRandom()
env.updateMap()

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

while (1):
    a.tick()