示例#1
0
    def listen(self, hero):
        ''' Listens for all key events '''

        for event in pg.event.get():
            self.quit(event)

            if event.type == pg.KEYDOWN:

                movement(event, hero)
                self.attack(event)
示例#2
0
def test_movement():
    struc = np.load("Utils/test_data/test_struc.npy")
    real_movement = np.load("Utils/test_data/test_movement.npy")
    start_time = time.time()
    pass_movement = mv.movement(struc)
    print("test_movement", str(time.time() - start_time))
    assert ((pass_movement - real_movement) < 1e-10)
示例#3
0
def round(player_stats, file_path, hero):
    os.system('clear')
    tablica = []
    tablica = importboard.make_a_bord(file_path)

    board_len_column = len(tablica) - 1
    board_len_row = len(tablica[0]) - 2

    user_position_coordinates = (2, 10, 3)

    tablica[user_position_coordinates[0]][user_position_coordinates[1]] = hero
    infoprint.print_board(tablica)
    display_player_stats(player_stats, user_position_coordinates[2])

    user_move = ''
    while user_move != 'q' and player_stats[
            'Luck'] > 0 and user_position_coordinates[2] < 4:
        user_move = movement.getch()
        os.system('clear')
        user_position_coordinates = movement.movement(
            user_move, tablica, user_position_coordinates[0],
            user_position_coordinates[1], board_len_column, board_len_row,
            user_position_coordinates[2], player_stats)
        infoprint.print_board(tablica)
        display_player_stats(player_stats, user_position_coordinates[2])

    if user_position_coordinates[2] == 4 and player_stats['Keys'] == 0:
        os.system('clear')
        return (True, player_stats)
    else:
        os.system('clear')
        infoprint.final_screen()
        return (False, player_stats)
示例#4
0
 def _process_row(self, row):
     price = float(row["Close"])
     if self._stock_history.movements:                
         if price > self._stock_history.movements[-1].price:
             difference = price - self._stock_history.movements[-1].price
             m = movement("UP", price, difference, row["Date"] )
         elif price < self._stock_history.movements[-1].price:
             difference = self._stock_history.movements[-1].price - price    
             m = movement("DOWN", price, difference, row["Date"] )
         else:
             difference=0
             m=movement("NONE", price, difference, row["Date"])    
     else:
         difference = 0
         m=movement("NONE", price, difference, row["Date"] )
                 
     self._stock_history.addMovement(m)    
示例#5
0
def round(player_stats, file_path, hero):
    os.system('clear')

    tablica = []
    tablica = importboard.make_a_bord(file_path)

    board_len_column = len(tablica) - 1
    board_len_row = len(tablica[0]) - 2

    user_position_coordinates = (1, 1, 2)

    tablica[user_position_coordinates[0]][user_position_coordinates[1]] = hero
    infoprint.print_board(tablica)
    display_player_stats(player_stats, user_position_coordinates[2])

    time_point = time.time()
    user_move = ''
    index_r = 0
    index_c = 0
    flag = 0

    while user_move != 'q' and player_stats[
            'Life'] > 0 and user_position_coordinates[2] < 3:
        user_move = movement.getch()
        os.system('clear')
        user_position_coordinates = movement.movement(
            user_move, tablica, user_position_coordinates[0],
            user_position_coordinates[1], board_len_column, board_len_row,
            user_position_coordinates[2], player_stats)

        if flag == 0:
            index_r = random.randint(0, len(tablica[0]) - 1)
            index_c = random.randint(0, len(tablica) - 1)
            while tablica[index_c][index_r] == '#' or tablica[index_c][
                    index_r] == '\n' or tablica[index_c][index_r] == hero:
                index_r = random.randint(0, len(tablica[0]) - 1)
                index_c = random.randint(0, len(tablica) - 1)
            tablica[index_c][index_r] = '?'
            flag = 1
            time_point = time.time()

        if time.time() >= time_point + 7:
            tablica[index_c][index_r] = '.'
            flag = 0

        infoprint.print_board(tablica)
        display_player_stats(player_stats, user_position_coordinates[2])

    if user_position_coordinates[2] == 3:
        os.system('clear')
        return (True, player_stats)
    else:
        os.system('clear')
        infoprint.final_screen()
        return (False, player_stats)
示例#6
0
 def __init__(self):
         self.movement = movement()
         self.kick = kick()
         self.TCP_IP = '192.168.1.120'#my computer
         self.TCP_PORT = 5005
         self.BUFFER_SIZE = 20  # Normally 1024, but we want fast response
         self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         print "before bind"
         self.s.bind((self.TCP_IP, self.TCP_PORT))
         print "before listen"
         self.s.listen(2)
         print 'before accept'
示例#7
0
    def move(self):
        from grid import grid

        self.direction = movement(self.exits)
        if self.direction == 'n':
            grid([self.coord[0], self.coord[1] - 1]).enter()
        elif self.direction == 's':
            grid([self.coord[0], self.coord[1] + 1]).enter()
        elif self.direction == 'e':
            grid([self.coord[0] + 1, self.coord[1]]).enter()
        elif self.direction == 'w':
            grid([self.coord[0] - 1, self.coord[1]]).enter()
        else:
            print("Error: Room.move() was passed an invalid argument.")
            exit(0)
示例#8
0
def start_module(game_map):
    """ Loads the selected map (default if none given)
    Arguments: 
        game_map: a list in list with the selected map
    Returns:
        None, it just prints the map """
    win_zones = define_coords_of_searched_letter(game_map, "S")
    score_list = {"Steps": 0, "Push": 0}
    actual_map = game_map
    while True:
        check_win_condition(actual_map, win_zones)
        ui.print_table(actual_map, score_list)
        next_move = ui.get_input(["Make your move!, Q for exit"])
        while next_move[0] not in "wWaAsSdDqQ":
            next_move = ui.get_input(["Make your move!, Q for exit"])
        if next_move[0] == "q":
            return False
        actual_map = movement.movement(actual_map, str(next_move[0]))
game_continue=0
while game_continue==0:
    game_grid=init_game(4)
    interface(game_grid)
    game_continue=whether_the_game_is_over(game_grid)
    while game_continue==1:
        game_continue=whether_the_game_is_over(game_grid)
        if game_continue==0:
            break
        move= read_player_command()
        grid = create_grid(4)
        for i in range(0,4):
            for j in range(0,4):
                grid[i][j]=game_grid[i][j]
        movement(game_grid,move)
        game_grid=grid_add_new_tile(game_grid)
        while grid==game_grid:
            print("UNABLE TO MOVE THIS WAY")
            move= read_player_command()
            movement(game_grid,move)
        interface(game_grid)
        pool=[]
        for i in range (0,4):
            for j in range (0,4):
                if game_grid[i][j]==' ':
                    pool.append(0)
                else:
                    pool.append(int(game_grid[i][j]))
        score=0
        for score_count in range (16):
示例#10
0
 def __init__(self, name = '', command_echelon = 'Team', side = 'BLUE', template=None, sim = None):    
   # Pointer to Simulator (non-templated)
   self.sim = sim
   
   # identity (non-templated)
   self['name'] = name
   self['side'] = side
   
   # Command echelon level
   self['command_echelon'] = command_echelon
   self['echelon_name'] = name
   
   # Actual unit size
   self['size'] = 'Team'
     
   # TOE (Get rid of TOE as public variable)
   self.template = template
   self['TOE'] = ''
   self.personel = {}
   self.vehicle = {}
   self['sensors'] = []
   
   # Logistics ###############################
   self.cargo = supply_package()
   
   # Command and Control #####################
   # Human factors in the TOEM format
   self['fatigue'] = self['morale'] = self['suppression'] = 0
   
   # Pointer to HIGHER and TF HIGHER (if any)
   self['HQ'] = None
   self['OPCON'] = None
   
   # List of immediate subordinates
   self['subordinates'] = []
   self['detached'] = []
   
   # Intelligence state data
   self['contacts'] = {}
   
   # Communications and Situations
   self['SITREP'] = {}
   self.COMMindex = 0
   self.COMMNets = []
   
   
   # Agents ##################################
   self['agent'] = agent(self)
   self.agentData = {}
   self['log'] = sandbox_log()
   self['staff queue'] = []
   self['OPORD'] = OPORD()
   
   # Location, heading, speed and disposition (non-templated)
   self.SetPosition( position_descriptor() ) #vect_5D()
   self['stance'] = 'deployed'
   self['readiness'] = 0.0
   self['dismounted'] = True
   
   # Blank models (In case the templates are incomplete)
   self.SetModelCombat(combat())
   self.SetModelIntelligence(intelligence())
   self.SetModelC4I(C4I())
   self.SetModelLogistics(logistics())
   self.SetModelMovement(movement())
   
   # Misc internal stuff
   self['ground engagements'] = []
   self['activities this pulse'] = []
   self['last pulse'] = None
   
   # Overiding Icon symbol
   self['icon'] = {}
   self['icon']['IFF'] = 'FRIEND'
   self['icon']['type'] = MapSym[self['TOE']][1]
   self['icon']['char'] = MapSym[self['TOE']][0]
    
   # template information
   if self.sim and self.template:
     self.sim.data.FetchData(self, 'unit', self.template)
     
   # Set the cargo to the capacity to a basic load
   if not self.cargo:
     self.cargo = self.GetBasicLoad(self)
示例#11
0
import Hand
import Head
import movement
import RPi.GPIO as GPIO

GPIO.cleanup()  # reset GPIO

LeftHand = Hand.Hand(3, 5, 7, 8, 10)
RightHand = Hand.Hand(11, 13, 15, 12, 16)
BigHead = Head.Head(19, 21, 23, 22, 24)
movesystem = movement.movement(22, 24, 36, 35)
p_u = .25
p_d = .25
p_mn = 0
probabilities = [p_r, p_l, p_u, p_d, p_mn]
iterations = 0

memory = {(m, n)}
locations = [[-1.5, 0], [-1, -0.5], [-1, 0.5], [-0.5, -1], [-0.5, 0],
             [-0.5, 1], [0, -1.5], [0, -0.5], [0, 0.5], [0, 1.5], [0.5, -1],
             [0.5, 0], [0.5, 1], [1, -0.5], [1, 0.5], [1.5, 0]]

while iterations < 200000:
    chemo = []
    for i in locations:
        if (m + i[0], n + i[1]) in memory:
            conc = 0
        else:
            conc = concentration(m + i[0], n + i[1], source_m, source_n)
        chemo.append(chemoattractant(conc, tip))

    transitions = transition(chemo, k)
    normal_transitions = normal_transition(transitions)
    probabilities = probability(normal_transitions, probabilities)
    m, n = movement(probabilities, memory, workspace, m, n, size, iterations)

    iterations += 1

plt.imshow(workspace)
cm.get_cmap("jet")
plt.show()
示例#13
0
 def __init__(self):
     self.movement = movement()
示例#14
0
    def __init__(self, name="", command_echelon="Team", side="BLUE", template=None, sim=None):
        # Pointer to Simulator (non-templated)
        self.sim = sim

        # identity (non-templated)
        self["name"] = name
        self["side"] = side

        # Command echelon level
        self["command_echelon"] = command_echelon
        self["echelon_name"] = name

        # Actual unit size
        self["size"] = "Team"

        # TOE (Get rid of TOE as public variable)
        self.template = template
        self["TOE"] = ""
        self.personel = {}
        self.vehicle = {}
        self["sensors"] = []

        # Logistics ###############################
        self.cargo = supply_package()

        # Command and Control #####################
        # Human factors in the TOEM format
        self["fatigue"] = self["morale"] = self["suppression"] = 0

        # Pointer to HIGHER and TF HIGHER (if any)
        self["HQ"] = None
        self["OPCON"] = None

        # List of immediate subordinates
        self["subordinates"] = []
        self["detached"] = []

        # Intelligence state data
        self["contacts"] = {}

        # Communications and Situations
        self["SITREP"] = {}
        self.COMMindex = 0
        self.COMMNets = []

        # Agents ##################################
        self["agent"] = agent(self)
        self.agentData = {}
        self["log"] = sandbox_log()
        self["staff queue"] = []
        self["OPORD"] = OPORD()

        # Location, heading, speed and disposition (non-templated)
        self.SetPosition(position_descriptor())  # vect_5D()
        self["stance"] = "deployed"
        self["readiness"] = 0.0
        self["dismounted"] = True

        # Blank models (In case the templates are incomplete)
        self.SetModelCombat(combat())
        self.SetModelIntelligence(intelligence())
        self.SetModelC4I(C4I())
        self.SetModelLogistics(logistics())
        self.SetModelMovement(movement())

        # Misc internal stuff
        self["ground engagements"] = []
        self["activities this pulse"] = []
        self["last pulse"] = None

        # Overiding Icon symbol
        self["icon"] = {}
        self["icon"]["IFF"] = "FRIEND"
        self["icon"]["type"] = MapSym[self["TOE"]][1]
        self["icon"]["char"] = MapSym[self["TOE"]][0]

        # template information
        if self.sim and self.template:
            self.sim.data.FetchData(self, "unit", self.template)

        # Set the cargo to the capacity to a basic load
        if not self.cargo:
            self.cargo = self.GetBasicLoad(self)