Sergey Kolosov :: sergeykolosov_0004.py

This bot has played 1560 games (656 wins / 168 draws / 736 losses).

Play against this bot as X or as O.

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

Bot P W D L Points Size From beginner One hit wonder Goldfish
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
Daniel Patrick : : error_unable_to_connect4.py (v2) 10 8 0 2 6 757 False False True
Tom Campbell : : winblockprevent.py (v5) 10 7 1 2 5 321 False False True
Jon Bannister : : anybot_r282.py (v5) 10 5 5 0 5 974 False False True

...and these bots have done worst

Bot P W D L Points Size From beginner One hit wonder Goldfish
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
house : : opportunist.py 10 0 0 10 -10 None None None None
Peter Inglesby : : random.py 10 0 0 10 -10 26 False True True

All standings against sergeykolosov_0004.py

The code

      
from random import random
from botany_connectfour.game import (
    available_moves,
    check_winner,
    make_move,
)


def get_next_move(board, token):
    moves = set(available_moves(board))
    other_token = {'X': 'O', 'O': 'X'}[token]

    for t in (token, other_token):
        for column in moves:
            next_board = [list(c) for c in board]
            make_move(next_board, column, t)
            if check_winner(next_board):
                return column

    if 3 in moves:
        return 3

    key = lambda value: random()
    for column in (
        sorted([2, 4], key=key) +
        sorted([1, 5], key=key) +
        sorted([0, 6], key=key)
    ):
        if column in moves:
            return column