house :: antagonist.py

This bot has played 2078 games (509 wins / 106 draws / 1463 losses).

Play against this bot as X or as O.

These bots have done best aganist antagonist.py...

Bot P W D L Points Size From beginner One hit wonder Goldfish
Jon Bannister : : anybot_r282.py (v5) 10 10 0 0 10 974 False False True
Robert Seaman : : not_minimax.py (v25) 10 10 0 0 10 3501 False False True
Séverin Hatt : : romuald_no_last_check.py (v1) 10 10 0 0 10 1598 False False True
Robert Howlett : : smart11.py (v1) 10 10 0 0 10 191 False False True
Tom Campbell : : winblockprevent.py (v5) 10 10 0 0 10 321 False False True

...and these bots have done worst

Bot P W D L Points Size From beginner One hit wonder Goldfish
Peter Inglesby : : random.py 10 1 0 9 -8 26 False True True
house : : anarchist.py 10 0 0 10 -10 None None None None
James Campbell : : horrible.py (v4) 10 0 0 10 -10 246 False False True
Ronan Murphy : : loser.py 10 0 0 10 -10 105 False False True
Luke Spademan : : lossingbot.py (v3) 10 0 0 10 -10 129 False False True

All standings against antagonist.py

The code

      
# This bot looks one move ahead, and if possible it will make a move to block
# its opponent winning.  Otherwise, it picks a move at random.

import copy
import random
from botany_connectfour import game


def get_next_move(board, token):
    available_moves = game.available_moves(board)

    if token == 'X':
        other_token = 'O'
    else:
        other_token = 'X'

    for col in available_moves:
        board1 = copy.deepcopy(board)
        game.make_move(board1, col, other_token)
        if game.check_winner(board1) is not None:
            return col

    return random.choice(available_moves)