27 lines
503 B
Python
27 lines
503 B
Python
import numpy as np
|
|
|
|
from a_player import APlayer
|
|
from numpy.random import uniform
|
|
|
|
|
|
class PlayerProvider:
|
|
def __init__(self, p1: APlayer, p2: APlayer):
|
|
self.players = [p1, p2]
|
|
|
|
def set_debug(self, with_debug):
|
|
for p in self.players:
|
|
p.set_debug(with_debug)
|
|
|
|
def choose(self, state: np.array) -> list[APlayer]:
|
|
# Wer fängt an?
|
|
players = self.players
|
|
if uniform() < 0.5:
|
|
players.reverse()
|
|
|
|
result = players
|
|
players[0].new_game(state)
|
|
players[1].new_game(state)
|
|
|
|
return result
|
|
|