Example #1
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import lib.interface as interface
import lib.utils as u
import lib.algorithms as algo

import signal
from subprocess import check_output
import os
IAName = "closest"

(mazeWidth, mazeHeight, mazeMap, preparationTime, turnTime, playerLocation, opponentLocation, coins, gameIsOver) = interface.initGame(IAName)
route = []
mazeMap[(-1,-1)] = ()
def next_way(playerLocation, coins):
    candidates = algo.dijkstra(mazeMap, playerLocation)
    dist = float("inf")
    coin = (-1,-1)
    for c in coins:
        if candidates[1][c] < dist:
            dist = candidates[1][c]
            coin = c
    coins.remove(coin)
    return u.way_width(candidates[0], playerLocation, coin)


def initialisationTurn(mazeWidth, mazeHeight, mazeMap, timeAllowed, playerLocation, opponentLocation, coins) :
    global route
    route = next_way(playerLocation, coins)
Example #2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import lib.utils as u
import lib.algorithms as algo
import lib.interface as api
import math
#import statistics as stats

IAName = "packagev2"

(mazeWidth, mazeHeight, mazeMap, preparationTime, turnTime, playerLocation,
 opponentLocation, coins, gameIsOver) = api.initGame(IAName)

best_weight = float("inf")
best_path = []
packages = {}
route_table = {}


def exhaustive(left, node, path, weight, coins_graph):
    """Fill best_path with the ROUTE to get all the coins in a minimal time"""
    global best_weight, best_path

    if len(left) == 0:
        if weight < best_weight:
            best_weight = weight
            best_path[:] = path

    else:
        for i in left:
Example #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# A simple IA that assume that the opponent is a greedy, try to kill him in 100% of the time

import lib.interface as interface
import lib.utils as u
# import lib.algorithms as algo


IAName = "I'll kill you"

(mazeWidth, mazeHeight, mazeMap, preparationTime, turnTime, playerLocation, opponentLocation, coins, gameIsOver) = interface.initGame(IAName)

dists_matrix, route_matrix = [], []
playerScore, enemyScore = 0, 0
old_coins = []
route = []


def get_closest_coin(player, coins, dists_matrix):
    closest_coin = coins[0]
    closest_coin_dist = dists_matrix[player][closest_coin]
    for coin in coins:
        coin_dist = dists_matrix[player][coin]
        if coin_dist < closest_coin_dist:
            closest_coin = coin
            closest_coin_dist = coin_dist
    return closest_coin, closest_coin_dist

Example #4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import lib.interface as interface
import lib.utils as u
import lib.algorithms as algo

import os
IAName = "closest2"

(mazeWidth, mazeHeight, mazeMap, preparationTime, turnTime, playerLocation,
 opponentLocation, coins, gameIsOver) = interface.initGame(IAName)
route = []
mazeMap[(-1, -1)] = ()


def next_way(playerLocation, coins):
    """  ͏͏ ͏͏  ͏­  ­   ͏­­ ­ ͏ ­   ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­ ͏   ͏   ­ ­ ͏   ͏ ­  ͏͏ ͏­­ ͏ ­ ­­  ͏ ­ ͏ ­  ͏͏ ͏ ͏ ͏­­ ­ ͏ ͏   ͏ ͏ ­   ͏­͏ ͏ ­ ͏   ͏͏  ͏­͏ ͏    ͏­ ͏­  ͏­͏ ­ ­ ­   ͏­  ͏͏  ­   ͏͏  ͏ ­ ͏͏  ͏ ­ ͏͏   ͏­ ­    ­   ͏­ ­   ­͏͏  ­  ͏   ͏ ͏ ͏­­ ­ ͏ ͏   ͏­  ͏   ͏͏  ͏­͏ ͏   ͏ ­ ͏­͏ ͏­­ ­   ͏   ͏­͏ ͏͏   ­­  ­­ ͏ ͏ ͏͏  ͏­  ͏    ­­  ­­ ͏­  ͏ ͏ ­ ͏ ͏ ͏ ͏­  ͏ ͏ ­   ­   ͏ ͏ ͏­  ­͏  ͏ ͏ ͏͏  ͏   ͏͏  ͏ ͏ ͏   ͏­  ͏­͏ ­ ­ ­   ͏   ­ ͏ ­   ­ ­ ­ ­ ͏͏  ­   ͏͏  ͏͏  ͏ ­ ͏   ͏   ͏ ͏ ͏ ­ ͏͏   ­  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ͏ ͏ ­­   ͏­ ͏­  ͏   ͏ ͏ ͏­­ ­ ͏ ͏   ͏­  ͏   ͏͏  ͏­͏ ͏   ͏   ­ ͏ ͏   ͏­  ͏͏  ͏ ͏ ­   ͏­͏ ͏ ­ ͏   ͏͏­ ͏   ͏ ­ ͏­͏  ­­  ­­ ͏   ͏­­ ͏ ­  ­­  ­­ ͏ ­ ͏͏  ͏­͏ ­ ­ ­   ͏­  ͏͏  ­   ͏͏  ͏ ­ ͏͏  ­ ͏ ͏͏  ­   ­ ­ ­͏  ­ ­ ͏͏  ͏͏   ­   ͏͏ ͏   ͏   ͏   ͏   ͏­­ ͏ ­ ͏͏­ ­­  ͏ ­ ͏ ­ ͏­͏ ͏͏͏ ͏­­ ͏͏  ͏­͏ ͏͏  ͏ ͏  ͏­ ͏͏   ­  ͏   ͏ ͏ ͏­­ ­ ͏ ͏   ͏͏  ͏   ͏͏  ͏­͏ ͏   ­ ͏ ͏   ͏­͏ ͏ ­ ͏   ͏͏  ­   ͏­  ͏­  ͏   ͏­͏ ͏͏  ͏ ͏ ͏͏  ͏­  ­ ͏ ͏͏  ͏͏   ͏͏ ͏ ͏ ͏­­ ­ ͏ ͏   ͏͏  ͏­  ͏   ͏   ͏͏  ͏­͏ ͏   ͏   ͏­͏ ­   ͏­  ͏   ­ ͏ ͏   ­   ͏   ͏͏   ͏­ ­ ­ ­ ͏ ͏­  ͏   ­   ­ ͏ ­   ͏­  ͏   ­͏  ­   ­ ­ ͏­  ͏   ­   ­ ­ ­ ­  ­  ͏͏  ­͏͏ ͏   ͏­­ ͏ ­ ͏   ­­  ͏   ͏­­ ͏ ­ ͏­͏ ­ ͏ ͏   ­   ͏­  ͏   ͏ ­ ͏   ͏͏  ͏ ­ ͏͏  ­ ͏ ͏͏  ͏   ͏͏  ͏­  ­ ­ ­   ­ ͏ ͏͏  ͏͏  ͏͏  ͏͏   ͏͏ ͏   ­͏  ͏   ͏ ­ ͏͏  ͏ ­ ͏ ­ ͏­͏ ͏͏͏ ͏­­ ͏͏  ͏­͏ ͏͏  ͏ ­ ͏͏  ­ ͏ ͏͏  ͏͏  ͏­͏ ­   ͏͏  ͏­­ ͏ ­  ͏­ ͏͏  ­͏͏ ͏͏  ͏͏­ ­    ­  ͏­  ­   ͏͏  ͏͏  ͏   ͏ ͏ ͏­­ ­ ͏ ͏   ͏͏  ͏   ͏͏  ͏­͏ ͏   ­ ͏ ͏   ͏­͏ ͏ ­ ͏   ͏͏  ­   ͏­  ͏­  ͏   ͏­͏ ͏͏  ͏­­ ͏ ­ ͏͏  ͏­  ­   ͏͏  ͏͏  ͏͏   ͏͏
    Cette fonction܁ ͏͏  ͏­  ­   ͏­­ ­ ͏ ­   ͏   ͏­­ ­ ­  ͏͏ ͏ ͏ ­ ͏ ͏­­ ͏­  ͏   ­ ­ ­   ͏ ͏ ­   ­ ͏ ͏­­ ͏ ­ ͏   ­ ­ ­ ­ ͏   ͏͏  ͏­  ­   ͏­­ ­ ͏ ­   ͏   ͏ ­ ͏͏  ͏   ͏ ­ ͏͏­  ­­ ͏­­ ­   ­   ­   ­   ­   ͏­  ͏       ͏­­ ­   ͏   ͏­͏ ͏­  ͏        ͏           ͏͏ ͏͏  ͏­  ­   ͏­­ ­ ͏ ­   ͏   ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­   ͏͏ ͏ ͏ ­ ͏ ͏­­ ͏­  ͏   ­܁
    est܁   ͏͏  ͏­  ͏   ͏   ͏͏  ͏­  ­   ͏­­ ­ ͏ ­   ͏   ­ ­ ͏­  ͏   ͏   ­    ͏͏ ͏͏  ͏­  ­   ͏­­ ­ ͏ ­   ͏   ͏ ­ ͏­­ ͏   ͏   ͏ ­ ­ ­  ͏͏ ͏͏  ͏­  ­   ͏­­ ­ ͏ ­   ͏   ͏͏  ͏   ­ ­ ͏͏  ͏­  ͏͏  ͏ ͏  ͏͏  ͏͏ ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏͏  ͏   ͏   ­­  ͏   ͏­­ ­ ­ ͏­͏ ­   ͏­­ ­   ͏   ͏­͏ ͏͏  ͏ ͏ ­   ­ ­ ͏   ͏­  ­   ͏   ͏   ͏   ͏  ܁
    plutot܁ ͏­  ͏­­ ­   ­   ͏͏  ͏   ­­  ͏ ͏ ͏   ͏   ͏   ͏­­ ­ ­ ͏­͏ ͏ ­ ͏   ­   ­   ­   ͏͏  ͏   ͏͏  ͏͏  ͏͏  ͏­͏ ­ ͏ ͏   ͏   ͏   ͏͏  ͏͏  ͏­͏ ­ ­ ­   ­ ͏ ͏͏  ­   ͏͏  ͏͏   ͏͏ ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏   ­   ͏͏  ͏   ­­  ͏   ͏­­ ­ ­ ͏­͏ ­   ͏­­ ­   ͏   ͏­͏ ͏͏  ͏ ͏ ­ ͏ ͏   ͏   ͏   ͏­  ͏͏  ͏­͏ ͏͏­ ͏   ͏­  ͏ ͏ ͏   ͏­­ ­   ­ ͏ ͏܁
    cool܁­­ ͏ ­ ͏­­ ͏   ­ ­ ͏­­ ͏   ­͏  ͏   ͏ ͏ ͏   ͏   ͏   ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏͏  ͏   ͏͏  ͏­͏ ­ ͏ ͏   ͏   ͏   ͏͏  ͏͏  ͏­͏ ­ ­ ­   ­ ͏ ͏͏  ­   ͏͏  ͏͏   ͏͏  ͏͏ ͏   ͏­͏  ­­ ­   ͏͏  ͏   ͏   ­­  ͏   ͏­­ ­ ­ ͏­͏ ­   ͏­­ ­   ͏   ͏­͏ ͏͏  ͏ ͏ ­   ­ ­ ­   ­ ͏ ͏   ͏   ͏   ͏­  ­   ͏   ͏ ͏ ͏͏­ ͏   ­ ­ ­   ­ ͏ ͏͏  ­   ­͏  ­ ͏܁
    en effet tout est dedans܁ ͏   ­    ­­ ­   ͏͏  ͏   ͏͏  ͏   ͏͏­ ͏   ͏ ͏ ͏   ­­  ͏   ͏ ­ ­ ͏ ͏   ­   ͏   ͏­  ͏­­ ͏   ͏ ­ ͏͏   ͏­ ­   ͏­  ­͏   ­   ­  ͏͏­ ͏͏  ͏ ­ ͏   ­­  ͏   ͏ ­ ­ ͏ ͏   ­   ͏   ͏­  ͏­­ ͏   ͏ ­  ͏­ ­   ͏­  ­͏   ­   ­  ͏͏­ ͏ ­ ͏ ͏ ͏͏  ͏­͏ ­ ͏ ͏   ͏   ͏   ͏͏  ͏͏  ͏­͏ ­ ­ ­   ͏­  ͏͏  ­   ͏͏  ͏͏   ͏͏ ͏   ͏­͏  ­­ ­   ͏͏  ͏   ͏   ­܁
    mais il faut faire attention܁­  ͏    ͏­ ­   ͏   ͏ ͏ ͏­­ ­ ͏ ͏   ­   ͏   ͏͏  ͏­͏ ͏   ͏   ͏­͏  ­­ ­   ͏͏  ͏   ͏   ͏͏  ͏ ͏ ͏   ͏͏  ͏­͏ ­   ͏͏  ­   ͏͏  ͏   ͏­͏ ͏­­ ­   ͏   ͏͏  ͏­͏ ͏   ͏͏  ͏­­ ­ ­ ͏­͏ ͏ ­ ͏   ­   ­   ͏͏  ͏   ͏͏  ͏͏  ͏­  ͏   ͏͏  ͏­͏ ­   ͏͏  ­   ­͏  ­ ͏ ͏   ­    ­­ ­   ͏͏  ͏   ͏͏  ͏͏   ­   ͏͏  ͏͏  ͏͏ ͏   ͏   ͏ ͏ ͏   ͏­͏ ͏­­ ­   ͏͏ ܁
    car sinon on ne pourra rien décoder܁ ͏͏  ­ ­ ͏͏  ͏ ­ ͏­͏ ­   ͏­  ͏­  ͏   ­ ­ ­   ͏   ͏ ­ ͏͏­ ͏͏  ­͏͏  ͏͏ ͏   ͏   ͏   ͏   ­   ͏   ­ ­ ­ ­  ͏͏  ͏͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏͏  ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏   ­  ͏    ­       ­         ͏­  ͏   ͏­͏ ͏­­ ­   ͏͏  ͏͏   ͏͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏͏  ­ ­ ͏܁
    de plus les jours nous sont comptés܁͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏   ­  ͏    ­  ͏   ­   ­  ͏­  ͏   ͏­͏ ͏­­ ­   ͏͏  ͏͏   ͏͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏͏  ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏   ­  ͏    ­           ͏  ­  ͏­  ͏   ͏­͏ ͏­­ ­   ͏͏  ͏͏   ͏͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏ ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏͏  ­ ­ ͏͏  ͏ ­ ͏­͏ ͏   ͏­  ͏­͏   ­  ͏ ܁
    """
    candidates = algo.dijkstra(mazeMap, playerLocation)
    dist = float("inf")
    coin = (-1, -1)
    for c in coins: