-
Notifications
You must be signed in to change notification settings - Fork 1
Getting started
Okay, you want to realize strategy for a cool game.
Let's find out what is a strategy. A strategy is a function, which gets current game state and number of player, for which it needs to play. This function returns turn, which strategy is going to make.
Of course, game states and turns are different for different games. Their description for a certain game is available in its statement.
Now all strategies should be written on Python 3. Here is an example of a simple strategy for Tic-Tac-Toe 3x3.
import random
def Strategy(classesModule, gameState, playerId: int) -> Turn:
while True:
i, j = random.randint(0, 2), random.randint(0, 2);
if (gameState.a[i][j] == '.'):
return classesModule.Turn(i, j);The strategy gets classesModule module, where is the definition of classes of game state and turn. There should be function Strategy with given signature, which should return classesModule.Turn class object. gameState is an object of classesModule.GameState class. playerId is an integer --- 0 or 1.
This strategy makes a random move, but you can create something more clever. HF & GL!
See also: Testing verdicts, Tournaments.