def meilleur_apres(liste):
    liste_apres = []
    for b in liste:
        a = baground.baground_test1(n)
        c = principal(it, a, b)
        liste_apres.append((c[1], c[0], b))
    liste_apres = sorted(liste_apres, reverse=True)
    return (liste_apres)
Exemplo n.º 2
0
def principal(nbiteration):
    a = baground.baground_test1(n)
    b = strategie.strategie(a)
    c = iteration.deepcopy(a)
    score = 0
    i = 0
    while i < nbiteration and score < vivants:
        c, score = iteration.avance(c, b, score)
        i += 1
    return (a, b, c, score, i)
def fusion_liste(liste, n):
    l = []
    i = len(liste)
    for x in range(i // 4):
        l.append(deepcopy(liste[x][2]))
    for x in range(i // 4):
        l.append(
            fusion1(deepcopy(liste[2 * x][2]), deepcopy(liste[2 * x + 1][2]),
                    n))
    for x in range(i // 4):
        l.append(
            fusion2(deepcopy(liste[x][2]), deepcopy(liste[x + i // 2][2]), n))
    for x in range(i // 4):
        l.append(strategie.strategie(baground.baground_test1(n)))
    return (l)
def meilleur_init():
    """
    renvoie la liste :
        [0]: score
        [1]: nbiteration max
        [2]: la table de strategie
    """
    liste = []
    for x in range(i):
        a = baground.baground_test1(n)
        b = strategie.strategie(a)
        c = principal(it, a, b)
        liste.append((c[1], c[0], b))
    liste = sorted(liste, reverse=True)
    return (liste)
Exemplo n.º 5
0
def meilleur_apres(liste):
    """
    renvoie la liste :
        [0]: score
        [1]: nbiteration max
        [2]: la table de fin
        [3]: la table de debut
        [4]: la table de strategie
    """
    liste_apres = []
    for b in liste:
        a = baground.baground_test1(n)
        c = principal(it, a, b)
        liste_apres.append((c[1], c[2], c[0], b))
    liste_apres = sorted(liste_apres, reverse=True)
    return (liste_apres)
Exemplo n.º 6
0
def fusion_liste(liste, n):
    """
    renvoie la liste :
        [0]: score
        [1]: nbiteration max
        [2]: la table de fin
        [3]: la table de debut
        [4]: la table de strategie
    """
    l = []
    i = len(liste)
    for x in range(i // 4):
        l.append(deepcopy(liste[x][3]))
    for x in range(i // 4):
        l.append(
            fusion1(deepcopy(liste[2 * x][3]), deepcopy(liste[2 * x + 1][3]),
                    n))
    for x in range(i // 4):
        l.append(
            fusion2(deepcopy(liste[x][3]), deepcopy(liste[x + i // 2][3]), n))
    for x in range(i // 4):
        l.append(strategie.strategie(baground.baground_test1(n)))
    return (l)
import baground
import iteration
import strategie
from copy import deepcopy


def nbvivant(t, n):
    res = 0
    for i in range(n):
        for j in range(n):
            if t[i][j] == 1:
                res += 1
    return (res)


vivants = nbvivant(baground.baground_test1(n), n)


def meilleur_init():
    """
    renvoie la liste :
        [0]: score
        [1]: nbiteration max
        [2]: la table de strategie
    """
    liste = []
    for x in range(i):
        a = baground.baground_test1(n)
        b = strategie.strategie(a)
        c = principal(it, a, b)
        liste.append((c[1], c[0], b))
Exemplo n.º 8
0
1 : il y a quelqu un
2 : mur
"""

n = 10
import tkinter
import random
from copy import deepcopy
"""
rajout
"""
import baground

k = 50

a = baground.baground_test1(n)

dico = {-1: "red", 2: "yellow", 1: "blue", 0: "white"}

score = 0


def init():
    for x in range(n):
        for y in range(n):
            couleur[y][x] = canvas.create_rectangle(
                (x * k, y * k, (x + 1) * k, (y + 1) * k),
                outline="gray",
                fill="red")