예제 #1
0
                maxC = coins
                maxP = p
    
    return maxP

def findCurPos(symbol,matrix):
    return [(index, row.index(symbol)) for index, row in enumerate(matrix) if symbol in row]

# parsing
parser = argparse.ArgumentParser(description="Marios findShortestPath",conflict_handler="resolve")
parser.add_argument('-p', '--player', required=True, help='symbol of player')
parser.add_argument('-b', '--board', required=True, help='Path to file that contains the board encoded as text.')
parser.add_argument('-h', '--history', required=True, help='history file path')
args = parser.parse_args()
    
currentBoard = FileReader.readBoard(args.board)
'''BoardInfo Properties
        # c == after all coins are collected; d == after one player has 10 coins (infinite coins)
        StopCriterion = c or p
        MaximalCoins = int
        RemainingCoins = int
        PlayerCoins = {}
        PlayerPositions = {}
        PlayerList = []
        Map = [[]]
    '''

matrix = currentBoard.Map
enemyPos = currentBoard.PlayerPositions[getPlayerWithMostCoins(currentBoard)]
posPlayer = currentBoard.PlayerPositions[args.player]
ownCoins = currentBoard.PlayerCoins[args.player]
    if (xc >= rowMax) and (x == 0):
        bestOption = 'N'
    if (y >= colMax) and (yc == 0):
        bestOption = 'E'
    if (yc >= colMax) and (y == 0):
        bestOption = 'W'
    return bestOption  
        

if __name__ == "__main__":
    args = parser.parse_args()
    Name = args.player
    BoardFile = args.boardFile
    HistoryFile = args.historyFile 
    
    currentBoard = FileReader.readBoard(BoardFile)
    '''BoardInfo Properties
        # c == after all coins are collected; d == after one player has 10 coins (infinite coins)
        StopCriterion = c or p
        MaximalCoins = int
        RemainingCoins = int
        PlayerCoins = {}
        PlayerPositions = {}
        PlayerList = []
        Map = [[]]
    '''
    matrix = currentBoard.Map        
    graph = matrixToGraph(matrix)
    
    enemyPos = getPlayerPosWithMostCoins(currentBoard)
    posPlayer = currentBoard.PlayerPositions[Name]
import math

# arguments:
parser = argparse.ArgumentParser(description='myBot', conflict_handler='resolve')
parser.add_argument("-p", "--player", action="store", type=str, required=True, help="Character on the map")
parser.add_argument("-b", "--boardFile", action="store", type=str, required=True, help="BoardFile.")
parser.add_argument("-h", "--historyFile", action="store", type=str, required=True, help="HistoryFile.")
args = parser.parse_args()


#moves = ["N", "S", "W", "E"]
#print random.choice(moves)
Name = args.player
BoardFile = args.boardFile
HistoryFile = args.historyFile 
board = FileReader.readBoard(BoardFile)
matrix = board.Map

Coin = '$'

def canMovePlayer(position):
    x,y = tuple(position)
    if(x < len(matrix) and y < len(matrix[0])):
        fieldType = matrix[x][y]
        if(fieldType == ' ' or fieldType == Coin):
            return True
        else:
            return False
    return False

#search player and coins