text_plain_output_1.png
import secrets
Jmin = 0
Jmax = 5
J = Jmin + secrets.randbelow(Jmax - Jmin + 1)
Dmin = 2
Dmax = 5
Hash = []
Map = []
MyMap = []
for D in range(Dmin, Dmax + 1):
    Hash.append([0, 0, 0])
    Map.append([{}, {}, {}])
    MyMap.append([{}, {}, {}])
G = 2
R = 0.4
V = 0.7
VM = 0.7
B = 0
def add(map1, hash1, A):
    if hash1 not in map1:
        map1[hash1] = {'S': 0}
    d = map1[hash1]
    if A not in d:
        d[A] = 1
    else:
        d[A] += 1
    d['S'] += 1
def match(map1, hash1, S):
    global B
    global J
    if hash1 not in map1:
        return
    d = map1[hash1]
    if d['S'] >= G:
        for A in range(S):
            if A in d and d[A] >= d['S'] * R + (1 - R) * G and (secrets.randbelow(101) < 100 * V):
                if secrets.randbelow(101) < 100 * VM:
                    B = (A + 1) % S
                else:
                    B = A % S
                J = Jmin + secrets.randbelow(Jmax - Jmin + 1)
def agent(observation, configuration):
    global B
    global J
    T = observation.step
    S = configuration.signs
    if T > 0:
        A = observation.lastOpponentAction
    BA = (B + 1) % S
    B = secrets.randbelow(S)
    for D in range(Dmin, Dmax + 1):
        if T > D:
            add(Map[D - Dmin][0], Hash[D - Dmin][0], A)
            add(Map[D - Dmin][1], Hash[D - Dmin][1], A)
            add(Map[D - Dmin][2], Hash[D - Dmin][2], A)
            add(MyMap[D - Dmin][0], Hash[D - Dmin][0], BA)
            add(MyMap[D - Dmin][1], Hash[D - Dmin][1], BA)
            add(MyMap[D - Dmin][2], Hash[D - Dmin][2], BA)
        if T > 0:
            Hash[D - Dmin][0] = Hash[D - Dmin][0] // S ** 2 + (A + S * B) * S ** (2 * D - 1)
            Hash[D - Dmin][1] = Hash[D - Dmin][1] // S + A * S ** (D - 1)
            Hash[D - Dmin][2] = Hash[D - Dmin][2] // S + B * S ** (D - 1)
        if J == 0:
            match(Map[D - Dmin][0], Hash[D - Dmin][0], S)
            match(Map[D - Dmin][1], Hash[D - Dmin][1], S)
            match(Map[D - Dmin][2], Hash[D - Dmin][2], S)
        if J == 0:
            match(MyMap[D - Dmin][0], Hash[D - Dmin][0], S)
            match(MyMap[D - Dmin][1], Hash[D - Dmin][1], S)
            match(MyMap[D - Dmin][2], Hash[D - Dmin][2], S)
    if J > 0:
        J -= 1
    return B