Open essepuntato opened 4 years ago
import random
def place_stone(color, black, white):
possible_positions = {(x, y) for x in range(7) for y in range(7)}
positions_taken = black.union(white)
output_possible_positions = possible_positions.difference(positions_taken)
return f"{color}{random.sample(output_possible_positions, 1)}"
color = "black"
black_positions = {(1, 2), (4, 2)}
white_positions = {(2, 4), (4, 4)}
print(place_stone(color, black_positions, white_positions))
# It prints black[(2, 1)], for example
Implement the function below in Python, that takes in input the colour of the player who has to play the turn (parameter colour), the sets of coordinates (i.e. sets of tuples) of all the black stones (parameter black) and white stones (parameter white) already positioned on the board, and returns the x, y coordinate (a tuple) of a free intersection where to place a new colour stone. The coordinates of the various positions of the board are those ones defined in "the board" as in the AlphaGo material available online.
More info are available at https://doi.org/10.5281/zenodo.2204836.