def next_state(self):
     """Get next state according to current mode and state"""
     if self.mode == 0:  # Const pos
         return self.x[0], 0, self.x[2], 0
     elif self.mode == 1:  # Const vel
         return self.x[0] + self.x[1] * self.dt, self.x[1], self.x[2] + self.x[3] * self.dt, self.x[3]
     elif self.mode == 2:  # Const pos + rotation
         speed = randuniform(0, 1)
         bearing = randuniform(0, 2 * PI)
         return self.x[0], speed * math.cos(bearing), self.x[2], speed * math.sin(bearing)
     else:
         raise ValueError('State must be an integer 0, 1, or 2')
 def next_state(self):
     """Get next state according to current mode and state"""
     if self.mode == 0:  # Const pos
         return self.x[0], 0, self.x[2], 0
     elif self.mode == 1:  # Const vel
         return self.x[0] + self.x[1] * self.dt, self.x[
             1], self.x[2] + self.x[3] * self.dt, self.x[3]
     elif self.mode == 2:  # Const pos + rotation
         speed = randuniform(0, 1)
         bearing = randuniform(0, 2 * PI)
         return self.x[0], speed * math.cos(
             bearing), self.x[2], speed * math.sin(bearing)
     else:
         raise ValueError('State must be an integer 0, 1, or 2')
Exemple #3
0
 def _psaco_initialisation(self):
     self._c1 = 20.0
     self._c2 = 0.2
     self._c3 = 2.0 * pi
     self._dimension = 30
     self._min_velocity = -2.0
     self._max_velocity = 2.0
     self._max_inertia = 2.0
     self._min_inertia = 0.01
     self._cognitive_scaling = 0.5
     self._social_scaling = 1.0
     self._position = list()
     self._velocity = list()
     for i in range(0, self.dimension):
         self._position.append(randuniform(-15.0, 15.0))
     for i in range(0, self.dimension):
         self._velocity.append(randuniform(self.min_velocity, self.max_velocity))
     self._best_fitness = self.get_fitness()
     self._best_position = self.position
 def next_mode(self):
     """Pick next mode randomly according to current mode and transition matrix T_{i->j}"""
     Ti = self.Tij[self.mode,:]
     Ti_cum = np.cumsum(Ti)
     x = randuniform(0, 1)
     return np.argmax(x<Ti_cum)
            raise ValueError('State must be an integer 0, 1, or 2')


def distance(a, b):
    return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)


if __name__ == "__main__":
    NCELLS = 1
    BOUNDS = ((0,0), (100,100))

    # Initialize cells
    cells = []
    for i in range(NCELLS):
        # Random starting position
        x = randuniform(BOUNDS[0][0], BOUNDS[1][0])
        y = randuniform(BOUNDS[0][1], BOUNDS[1][1])

        # Random starting velocity
        speed = randuniform(0,1)
        bearing = randuniform(0, 2*PI)
        xdot = speed*math.cos(bearing)
        ydot = speed*math.sin(bearing)

        cells.append(CellWalker((x,xdot,y,ydot)))
        print('Cell with starting position ({x:.3f},{y:.3f}) and velocity ({xdot:.3f},{ydot:.3f}) created'.format(
            x=x, y=y, xdot=xdot, ydot=ydot))

    # Debug: advance cell a bunch of times
    #   This isn't necessary, but it's just here to show what's being calculated inside the cell
    nt = 150
 def next_mode(self):
     """Pick next mode randomly according to current mode and transition matrix T_{i->j}"""
     Ti = self.Tij[self.mode, :]
     Ti_cum = np.cumsum(Ti)
     x = randuniform(0, 1)
     return np.argmax(x < Ti_cum)
            raise ValueError('State must be an integer 0, 1, or 2')


def distance(a, b):
    return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)


if __name__ == "__main__":
    NCELLS = 1
    BOUNDS = ((0, 0), (100, 100))

    # Initialize cells
    cells = []
    for i in range(NCELLS):
        # Random starting position
        x = randuniform(BOUNDS[0][0], BOUNDS[1][0])
        y = randuniform(BOUNDS[0][1], BOUNDS[1][1])

        # Random starting velocity
        speed = randuniform(0, 1)
        bearing = randuniform(0, 2 * PI)
        xdot = speed * math.cos(bearing)
        ydot = speed * math.sin(bearing)

        cells.append(CellWalker((x, xdot, y, ydot)))
        print(
            'Cell with starting position ({x:.3f},{y:.3f}) and velocity ({xdot:.3f},{ydot:.3f}) created'
            .format(x=x, y=y, xdot=xdot, ydot=ydot))

    # Debug: advance cell a bunch of times
    #   This isn't necessary, but it's just here to show what's being calculated inside the cell
def damage(): 
  if move.atktype == phys:
    damagephys = ((42)*chosenmove.power)*(self.atk/opponent.defs))/ 50)+2)*random.randuniform(.88,1.12))
    if self.status = brn:
      x = damagephys/2
        self.hpmax = hpmax
        self.hpcurrent = hpcurrent
        self.atk = atk
        self.defs = defs
        self.spatk = spatk
        self.spdef = spdef
        self.spd = spd
        self.moves = moves
        self.status = status
def damage(): 
  if move.atktype == phys:
    damagephys = ((42)*chosenmove.power)*(self.atk/opponent.defs))/ 50)+2)*random.randuniform(.88,1.12))
    if self.status = brn:
      x = damagephys/2
  elif move.atktype = spec:
   x = ((((((((42)*chosenmove.power)*(self.spatk/opponent.spdef))/50)+2)*random.randuniform(.88,1.12))
  else:
    dmg = 0
def battleaction():
  x = input("Would you like to use a (M)ove or    (S)witch pokemon?")
  if x = M:
    y = input(f"What move would you like to use? You can pick from {self.moves}")
    y.pp - 1
    if y.pp = 0, 
  elif x = S:
    z = input("Which Pokemon would you like to switch to?")
    self = z
  else:
    print("Type either M or S, to use a (M)ove or (S)witch.")
    battleaction()
self = input("Which Pokemon would you like to send out first?")