house :: opportunist.py

This bot has played 2302 games (353 wins / 3 draws / 1946 losses).

Play against this bot as X or as O.

These bots have done best aganist opportunist.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
Dilwoar Hussain : : dee-bot.py (v12) 10 10 0 0 10 306 False False False
Daniel Patrick : : error_unable_to_connect4.py (v2) 10 10 0 0 10 757 False False True
Ian Ozsvald : : ian12.py 10 10 0 0 10 943 False False True
Joe Jordan : : jbot2.py (v4) 10 10 0 0 10 719 False False False

...and these bots have done worst

Bot P W D L Points Size From beginner One hit wonder Goldfish
Luke Spademan : : lossingbot.py (v3) 10 5 0 5 0 129 False False True
house : : anarchist.py 10 2 0 8 -6 None None None None
Peter Inglesby : : random.py 10 2 0 8 -6 26 False True True
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

All standings against opportunist.py

The code

      
# This bot looks one move ahead, and will make a winning move if one is
# available.  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)

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

    return random.choice(available_moves)