title: "None is not a generator" in Python - El Farol algorithm
body: <p>I'm writing El Farol model from Netlogo in Python. However, I keep receiving this error and I have no idea how to move on:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;ipython-input-444-99b2c0f618f2&gt;", line 3, in &lt;module&gt;
      village.run()
    File "&lt;ipython-input-441-cb8708c7230d&gt;", line 143, in run
      Agent(self)
    File "&lt;ipython-input-441-cb8708c7230d&gt;", line 22, in __init__
      self.village.env.process(self.move())
    File "C:\Users\jkowalczyk002\AppData\Local\Continuum\Anaconda3\lib\site-packages\simpy\events.py", line 272, in __init__
      raise ValueError('%s is not a generator.' % generator)
  ValueError: None is not a generator.
  </code></pre>
  
  <p>Messages indicate that there is something wrong with move() function, but to me it looks fine:</p>
  
  <pre><code>def move(self):
      new_loc = self.gen_loc()
      del self.village.occupied[self.loc]
      self.loc = new_loc
      self.village.data[self.loc] = 1
  </code></pre>
  
  <p>It should go from <code>move</code> -> <code>gen_loc</code> -> <code>najlepsza</code> (English - best) -> <code>do_baru</code> (E - to bar), but it gets <code>None</code>.</p>
  
  <p>Whole code:</p>
  
  <pre><code>import simpy
  import random
  import math
  
  import matplotlib.pyplot as plt
  import numpy as np
  import matplotlib.colors
  from gridplot import GridPlot
  
  white_green = matplotlib.colors.ListedColormap(["green","white"])
  plt.register_cmap(cmap=white_green)
  
  class Agent:
      def __init__(self,village):
          self.village = village
          self.color = 1
          self.loc = self.gen_loc()
          self.village.env.process(self.move())
  
      def gen_loc(self):
          if self.najlepsza()&lt;self.village.threshold:
              self.loc = (random.randrange(math.floor(self.village.village_dim/2)+1,self.village.village_dim),
                          random.randrange(math.floor(self.village.village_dim/2)+1,self.village.village_dim))
              if self.loc not in self.village.occupied:
                  self.village.occupied[self.loc] = self
          elif random.random()&gt;0.33:
              self.loc =(random.randrange(0,math.floor(self.village.village_dim/2)-1,
                         random.randrange(0,self.village.village_dim)))
              if self.loc not in self.village.occupied:
                  self.village.occupied[self.loc] = self
          else:
              self.loc =(random.randrange(math.floor(self.village.village_dim/2),self.village.village_dim),
              random.randrange(0,math.floor(self.village.village_dim/2)-1))
              if self.loc not in self.village.occupied:
                  self.village.occupied[self.loc] = self
  
      def najlepsza(self):
          if self.village.env.now&lt;2:
                  strategia=[]
                  for j in range(village.liczbastr):
                      for i in range(village.memorysize):
                          strategia.append(random.random())
                  sumy=[]
                  for j in range(village.liczbastr):
                      sumy.append(sum(strategia[i+village.memorysize*j] for i in range(village.memorysize)))
                  strategia1=[]
                  for j in range(village.liczbastr):
                      for i in range(village.memorysize):
                          strategia1.append(strategia[i+j*village.memorysize]/sumy[j])
                  listypre=[strategia1[i:i+village.memorysize] for i in range(0, village.memorysize*village.liczbastr, village.memorysize)]
                  zestaw1=np.array(listypre)
          historia1=village.historia
          wynikstrat=[]
          for j in range(village.liczbastr):
              for k in range(village.memorysize):
                  wynikstrat.append(sum(historia1[-i-2-k]*zestaw1[j,-i-1] for i in range(village.memorysize)))
          listypre=[]
          listypre=[wynikstrat[i:i+village.memorysize] for i in range(0, village.memorysize*village.liczbastr, village.memorysize)]
          tabela1=np.array(listypre)+10
          wynik=village.memorysize*100
          naj=village.liczbastr
          pred=0
          for j in range(village.liczbastr):
              if (sum(abs(tabela1[j,i]-historia1[-i-1]) for i in range(village.memorysize)))&lt;wynik:
                  wynik=sum(abs(tabela1[j,i]-historia1[-i-1]) for i in range(village.memorysize))
                  naj=j
          pred=sum(historia1[-1-i]*zestaw1[naj,-i-1] for i in range(village.memorysize))
          return(pred)
  
      def do_baru(self):
          return(self.najlepsza() &lt;= self.village.threshold)
  
      def move(self):
          new_loc = self.gen_loc()
          del self.village.occupied[self.loc]
          self.loc = new_loc
          self.village.data[self.loc] = 1
  
  class Village:
      def __init__(self, env, village_dim, memorysize, liczbastr,threshold):
          self.village_dim = village_dim
          self.memorysize = memorysize
          self.liczbastr = liczbastr
          self.threshold = threshold
          self.env=env
          self.historia=self.historialos()
  
      def historialos(self):
          if self.env.now&lt;2:
              historia=[]
              for i in range(2*self.memorysize):
                  historia.append(random.randint(0,100))
          return(historia)
  
      def histupdate(self):
          for i in range(2*self.memorysize):
              self.historia[i-1]=self.historia[i]
          self.historia[2*self.memorysize-1]=self.attendance()
          return(self.historia)
  
      def attendance(self):
          attend=0
          for v in self.occupied.values():
              if v.do_baru():
                  attend = attend+1
  
      def plot(self, start):
          self.data = np.zeros((self.village_dim, self.village_dim))
          for agent in self.occupied:
              self.data[agent] = self.occupied[agent].color
          self.gp = GridPlot(self.data, ["white", "green"])
  
      def run(self):
          self.occupied = dict()
          agent_count = 100
          print(self.historia)
          for i in range(agent_count):
              Agent(self)
          self.env.process(self.plot())
          self.histupdate()
  
  env = simpy.Environment()
  village = Village(env, 50,10,5,50)
  village.run()
  </code></pre>