Ejemplo n.º 1
0
 def tick_retreating(self, context):
     nearby = self.nearbyThings(self.attack_range + 2)
     if nearby:
         nearest = nearby[0]
         v = self.unitVector(nearest.pos, self.pos) * self.attack_range 
         if v == (0,0):
             v = (math.randint(0,1), math.randint(0, 1))
         target = self.pos[0] + v[0], self.pos[1] + v[1]
         self.begin_walkToward(target)
     else:
         self.states.remove('retreating')
Ejemplo n.º 2
0
 def tick_retreating(self, context):
     nearby = self.nearbyThings(self.attack_range + 2)
     if nearby:
         nearest = nearby[0]
         v = self.unitVector(nearest.pos, self.pos) * self.attack_range
         if v == (0, 0):
             v = (math.randint(0, 1), math.randint(0, 1))
         target = self.pos[0] + v[0], self.pos[1] + v[1]
         self.begin_walkToward(target)
     else:
         self.states.remove('retreating')
Ejemplo n.º 3
0
 def __init__(self):
     self.homeX = random.randint(0 - populationSpace, populationSpace) / 2
     self.homeY = random.randint(0 - populationSpace, populationSpace) / 2
     self.state = states[0]
     self.X = self.homeX
     self.Y = self.homeY
     self.leftHome = 0
     if (self.state == states[1]):  #Infected
         self.timeInfected = pCarrierTime + math.randint(0, pInfectionTime)
     elif (self.state == states[3]):  #Carrier
         self.timeInfected = math.randint(0, pCarrierTime)
     else:
         self.timeInfected = 0
		def calculate (results):
			low, high = results

			if low is None or high is None:
				return None

			return math.randint(low, high)
Ejemplo n.º 5
0
 def random(self):
     '''
     Return:
         - Returns a random value stored in the memory
     '''
     idx = math.randint(0, self.size() - 1)
     return (self.memory[idx])
Ejemplo n.º 6
0
def generateEdges(graph,nodes):

    for i in range(nodes):
        for j in range(nodes):
            graph[i][j] = randint(0,1)

    return graph
Ejemplo n.º 7
0
    def spawn(self, side, speed):
        if side == self.START_LEFT:
            angle = random.randint(20, 70)
            start_x = 0
        else:
            start_x = 640
            angle = random.randint(110, 160)

        self.direction = (math.cos(angle),
                          math.sin(angle))

        self.speed = math.randint(20, 100)
        self.set_position(start_x, 0)
Ejemplo n.º 8
0
from math import randint
dinheiro = 1000
programa = True
while programa == True and dinheiro > 0:
    aposta = input("Você quer apostar?(sim/não) ")
    if aposta == "não":
        print ("Você terminou a partida com {0} dinheiros".format(dinheiro))
        programa = False
    else:
        dado1 = randint(1,6)
        dado2 = randint(1,6)
        chute = int(input("Chute um valor: ")
        dinheiro = dinheiro - 30
        if chute == dado1 + dado2:
            dinheiro += 50
            print ("Você terminou a partida com {0} dinheiros".format(dinheiro))
        else:
            continuidade = input("Você quer continuar na partida?(continuar/desistir) ")
            if continuidade == "desistir":
                print ("Você terminou a partida com {0} dinheiros".format(dinheiro))
            else:
                chute = int(input("Chute um valor: ")
                dinheiro -= 20
                if chute == dado1 + dado2:
                    dinheiro += 50
                    print ("Você terminou a partida com {0} dinheiros".format(dinheiro))
                else:
                    print (dado1)
                    continuidade = input("Você quer continuar na partida?(continuar/desistir) ")
                    if continuidade == "desistir":
                        print ("Você terminou a partida com {0} dinheiros".format(dinheiro))
Ejemplo n.º 9
0
def random_sliver_start(cropped_image, desired_width):
    width = cropped_image.shape[1]
    return math.randint(0, width - desired_width)
Ejemplo n.º 10
0
 def randFrame(self):
     self._frame = math.randint(self._frameCount)