コード例 #1
0
ファイル: battle.py プロジェクト: JFYu95/Azurlane_script
def wait_battle():
    while True:
        if scan(success):
            move(success)
            break
        time.sleep(2)
    # 再判断战斗结束
    time.sleep(0.3)
    while scan(success):
        move(success)
        time.sleep(0.3)
コード例 #2
0
def gen(xmax, ymax):  # genere le tableau de base
    tab = []
    for y in range(ymax):
        line = []
        for x in range(xmax):
            if y == 0 and x == 0:
                line.append("1")
            elif y == ymax - 1 and x == xmax - 1:
                line.append("0")
            else:
                if y % 2 == 0:
                    if x % 2 != 0:
                        line.append("X")
                    else:
                        line.append("0")
                else:
                    line.append("X")
        tab.append(line)

    y = 0
    x = 0
    while not end(tab, ymax, xmax):
        y, x = move(tab, y, x, ymax, xmax)
        if goto_up(tab, x, y) == "no" and goto_down(
                tab, x, y,
                ymax) == "no" and goto_left(tab, x, y) == "no" and goto_right(
                    tab, x, y, xmax) == "no" and not end(tab, ymax, xmax):
            x, y = newway(tab, ymax, xmax)

    return tab
コード例 #3
0
 def randomWalks(self, board, rand):
     solved = False
     if not solved:
         for n in xrange(0, rand):
             gamePlay = self.moves(board, self.getBlocks(board))
             rand = randint(1, len(gamePlay.moves))
             newBoard = move.applyMove(move(), board,
                                       gamePlay.moves[(rand - 1)],
                                       gamePlay.blocks)
             normalizedBoard = self.normalize(newBoard)
             solved = self.isSolved(normalizedBoard)
             board = newBoard
             printDirection = ""
             if gamePlay.moves[(rand - 1)].direction == 0:
                 printDirection = "up"
             elif gamePlay.moves[(rand - 1)].direction == 1:
                 printDirection = "right"
             elif gamePlay.moves[(rand - 1)].direction == 2:
                 printDirection = "down"
             elif gamePlay.moves[(rand - 1)].direction == 3:
                 printDirection = "left"
             print('(', gamePlay.moves[(rand - 1)].block, ',',
                   printDirection, ')')
             self.show(board)
             print(solved)
コード例 #4
0
def histogram_localization(map_grid, measurements, motions, sensor_right, p_move, p_move_overshoot, p_move_undershoot):
    a_priory = 1.0 / (len(map_grid) * len(map_grid[0]))
    p_matrix = [ [ a_priory for row in range(len(map_grid))] for cols in range(len(map_grid[0]))]
    for i in range(len(map_grid)):
        w = [len(map_grid[i])]
        p_matrix.append(w)
    for i in range(len(motions)):
        p_matrix = move(p_matrix, motions[i], p_move)
        p_matrix = sense(p_matrix, measurements[i], map_grid, sensor_right, (1 - sensor_right))
    return p_matrix
コード例 #5
0
def main(form):
    """
    Parses incoming request of form /ttt func [args] and calls appropriate function. If invalid request format,
    returns help information to the user
    """
    values = {}
    teamkey = form['team_id']
    team_domain = form['team_domain']
    channelkey = form['channel_id']
    channel_name = form['channel_name']
    userkey = form['user_id']
    user_name = form['user_name']
    command = form['command']
    text = form['text']

    info = text.split()
    # No function specified
    if len(info) < 1:
        return help()
    func = info[0]
    # Start a new game. Ensure competing user is specfied, eg /ttt user @opponent
    if func == 'start':
        if len(info) < 2:
            return help()
        return startgame(teamkey, team_domain, channelkey, channel_name,
                         userkey, user_name, info)
    # Print game board
    elif func == 'status':
        num_moves = get_num_moves(channelkey, teamkey)
        if (num_moves < 0):
            return help()
        return printboard(teamkey, channelkey, num_moves)
    # Make a game move. Ensure position is specified, eg /ttt move [position]
    elif func == 'move':
        if len(info) < 2:
            return help()
        return move(teamkey, channelkey, userkey, info[1], user_name)
    # Forfeit current game
    elif func == 'forfeit':
        return forfeit(channelkey, teamkey, user_name)
    # Print total number of wins for this user
    elif func == 'wins':
        return wins(user_name, userkey, teamkey)
    # Return help info to user
    elif func == 'help':
        return help()
    else:
        data = {
            "response_type": "ephemeral",
            "text": "Invalid command for /ttt. Use /ttt help for more info"
        }

        resp = Response(json.dumps(data), mimetype='application/json')
        return resp
コード例 #6
0
def wakeUp(result, pinyin):
    if getPinYin("精神小伙") in pinyin:
        if getPinYin("你好") in pinyin:
            print("你好")
            getBaiduVoice("你好")
        elif getPinYin("开灯") in pinyin:
            onPublish("chat", "1", 1)
            print("灯已打开")
            getBaiduVoice("灯已打开")
        elif getPinYin("关灯") in pinyin:
            onPublish("chat", "5", 1)
            print("灯已关闭")
            getBaiduVoice("灯已关闭")
        elif getPinYin("听") in pinyin:
            downMusic(getMusicName(result))
        elif getPinYin("首") in pinyin:
            downMusic(getMusicName(result))
        elif getPinYin("前") in pinyin:
            move("front")
        elif getPinYin("后") in pinyin:
            move("back")
        elif getPinYin("左") in pinyin:
            move("left")
        elif getPinYin("右") in pinyin:
            move("right")

        elif getPinYin("天气") in pinyin:
            getBaiduVoice(getWeatherInfo(getCity(result)))
            temp = getWeatherInfo(get_address(get_url(), result))
            print(temp[0])
            mc.postToChat(
                rep(getPinYin(temp[1])) + "'s temporary:" + temp[2] + "C")
            pos = mc.player.getTilePos()
            mc.setBlocks(pos.x - 2, pos.y, pos.z + 8, pos.x + 2, pos.y + 30,
                         pos.z + 12, 0)
            for i in range(eval(temp[2])):
                mc.setBlock(pos.x, pos.y + i, pos.z + 10, 223)
                if i % 5 == 0:
                    mc.setBlock(pos.x, pos.y + i, pos.z + 10, 233)

        else:
            print("我在")
            playVoice("im.mp3")
コード例 #7
0
    def getMove(self):
        """
		Marks a square at coordinate (column, row) for player

		:param column: (int) the 0-indexed column of the Board to mark
		:param row: (int) the 0-indexed row of the Board to mark
		:param player: (str) the X or O representation of which player to mark in square

		:return: ????
		"""
        row = input("Enter a row: ")
        col = input("Enter a column: ")

        playerMove = move(row, col, self.name)

        return playerMove

        pass
コード例 #8
0
        pokemon1.attack(pokemon1.move, pokemon2)
        if pokemon2.current_hp <= 0:
            break
        pokemon2.attack(pokemon2.move, pokemon1)

    if (pokemon1.current_hp <= 0):
        print("\n", pokemon2.name, "Won the Battle!")

    else:
        print("\n", pokemon1.name, "Won the battle!")


# Passing Default parameters for the function Pokemon

pokemon1 = Pokemon(111, 'Pikachu', 1, 1, 'Electric', 'None',
                   move('Thunder Shock', 8.33), move('Thunder Shock', 8.33),
                   7.42, 0.47, 'M', 1.0)
pokemon2 = Pokemon(111, 'Squirtle', 1, 1, 'Water', 'None',
                   move('Water Gun', 5.0), move('Water Gun', 5.0), 7.42, 0.47,
                   'F', 1.0)

# Randomizing Values for both the Pokemon objects

pokemon1.randomize_status()
pokemon2.randomize_status()

## Before attack Values

print('Before Attack :\n')
print(pokemon1)
print('\n')
コード例 #9
0
ファイル: robot.py プロジェクト: QuantumApe/pi-bot
from server import * #importing network server class
from move import * #importing the move routines for the robot
 

#Scripting

if __name__ == '__main__':

  #Define attached pin atachments
  Right_R=17
  Right_F=4
  Left_R=21
  Left_F=22

  #setup move routines
  drive=move()
  drive.setup(Right_F,Right_R,Left_F,Left_R)


  #start server
  try:
    soc=server()
    ser=soc.setup(1337,5)
    connection,address = ser.accept()
    while 1:
      message=connection.recv(4096)
      if message == '':
        print "client cut connection, exiting"
        raise KeyboardInterrupt
    
      print message
コード例 #10
0
 def move_chinese(move_str):
     move_from, move_to = Move.from_chinese(self, move_str)
     return move(move_from, move_to)
コード例 #11
0
 def move_iccs(move_str):
     move_from, move_to = Move.from_iccs(move_str)
     return move(move_from, move_to)
コード例 #12
0
ファイル: Board.py プロジェクト: Fibonacci55/FoxMill
 def result(self, state, move):
     new_game = copy.deepcopy(self)
     move(new_game)
     return new_game
コード例 #13
0
    def moves(self, matrix, blocks):
        moves = []
        currblocks = []
        for b in blocks:
            for x in xrange(0, self.h):
                for y in xrange(0, self.w):
                    if self.matrix[x][y] == b:
                        #print('position of',b,'is: ',x,',',y)
                        for obj in currblocks:
                            if obj.id == b:
                                for pos in obj.position:
                                    if pos[0] != x:
                                        obj.height += 1
                                    if pos[1] != y:
                                        obj.width += 1
                                obj.position.append((x, y))
                                break
                        else:
                            newBlock = block()
                            newBlock.id = b
                            newBlock.height = 1
                            newBlock.width = 1
                            newBlock.position = []
                            newBlock.position.append((x, y))
                            currblocks.append(newBlock)
        for obj in currblocks:
            #print(obj.id,',',obj.height,',',obj.width,',',obj.position)
            moveUp = True
            moveRight = True
            moveDown = True
            moveLeft = True
            for pos in obj.position:
                if self.matrix[pos[0] - 1][pos[1]] != 0 and self.matrix[
                        pos[0] - 1][pos[1]] != obj.id:
                    moveUp = False
                if self.matrix[pos[0]][pos[1] + 1] != 0 and self.matrix[
                        pos[0]][pos[1] + 1] != obj.id:
                    moveRight = False
                if self.matrix[pos[0] + 1][pos[1]] != 0 and self.matrix[
                        pos[0] + 1][pos[1]] != obj.id:
                    moveDown = False
                if self.matrix[pos[0]][pos[1] - 1] != 0 and self.matrix[
                        pos[0]][pos[1] - 1] != obj.id:
                    moveLeft = False
            if moveUp:
                newMove = move()
                newMove.block = obj.id
                newMove.direction = 0
                moves.append(newMove)
            if moveRight:
                newMove = move()
                newMove.block = obj.id
                newMove.direction = 1
                moves.append(newMove)
            if moveDown:
                newMove = move()
                newMove.block = obj.id
                newMove.direction = 2
                moves.append(newMove)
            if moveLeft:
                newMove = move()
                newMove.block = obj.id
                newMove.direction = 3
                moves.append(newMove)

        #for obj in moves:
        #print('blockid:',obj.block,',direction:',obj.direction)
        gamePlay = game_play()
        gamePlay.blocks = currblocks
        gamePlay.moves = moves
        return gamePlay
コード例 #14
0
#from GPIO import * #importing Rasberry Pi GPIO control
from server import *  #importing network server class
from move import *  #importing the move routines for the robot

#Scripting

if __name__ == '__main__':

    #Define attached pin atachments
    Right_R = 17
    Right_F = 4
    Left_R = 21
    Left_F = 22

    #setup move routines
    drive = move()
    drive.setup(Right_F, Right_R, Left_F, Left_R)

    #start server
    try:
        soc = server()
        ser = soc.setup(1337, 5)
        connection, address = ser.accept()
        while 1:
            message = connection.recv(4096)
            if message == '':
                print "client cut connection, exiting"
                raise KeyboardInterrupt

            print message
            if message == 'w':
コード例 #15
0
ファイル: Board.py プロジェクト: Fibonacci55/FoxMill
 def result(self, state, move):
     new_game = copy.deepcopy(self)
     move(new_game)
     return new_game