Luke Spademan :: lossingbot.py (v3)

This bot has played 990 games (82 wins / 0 draws / 908 losses).

Play against this bot as X or as O.

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

Bot P W D L Points Size From beginner One hit wonder Goldfish
house : : antagonist.py 10 10 0 0 10 None None None None
Jon Bannister : : anybot_r282.py (v5) 10 10 0 0 10 974 False False True
Dan Miller : : board_bot.py 10 10 0 0 10 596 False False False
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

...and these bots have done worst

Bot P W D L Points Size From beginner One hit wonder Goldfish
Peter Inglesby : : random.py 10 4 0 6 -2 26 False True True
house : : anarchist.py 10 3 0 7 -4 None None None None
Stefano Chiodino : : bot.py (v2) 10 3 0 7 -4 183 False False 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 lossingbot.py

The code

      
import copy
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 i,col in enumerate(available_moves):
        board1 = copy.deepcopy(board)
        board2 = copy.deepcopy(board)
        game.make_move(board1, col, other_token)
        game.make_move(board2, col, token)
        if game.check_winner(board1) is None:
            return col
        if game.check_winner(board2) is not None:
            available_moves.pop(i)

    available_moves[0]