Jordan Banting :: trololololol.py (v1)

This bot has played 970 games (366 wins / 114 draws / 490 losses).

Play against this bot as X or as O.

These bots have done best aganist trololololol.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
Jon Bannister : : anybot_r282.py (v5) 10 5 5 0 5 974 False False True
Dilwoar Hussain : : dee-bot.py (v12) 10 5 0 5 0 306 False False False
Daniel Patrick : : error_unable_to_connect4.py (v2) 10 5 0 5 0 757 False False True

...and these bots have done worst

Bot P W D L Points Size From beginner One hit wonder Goldfish
Joe Jordan : : jbot2.py (v4) 10 0 0 10 -10 719 False False False
Mac Chapman : : lines.py 10 0 0 10 -10 893 False False False
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
Peter Inglesby : : random.py 10 0 0 10 -10 26 False True True

All standings against trololololol.py

The code

      
from botany_connectfour import game

def board_copy(board):
    return [row[:] for row in board]

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 = board_copy(board)
        game.make_move(board1, col, token)
        winner = game.check_winner(board1)
        if winner is token:
            return col
        else:
            board2 = board_copy(board1)
            new_available_moves = game.available_moves(board)
            if col in new_available_moves:
                try:
                    game.make_move(board2,col,other_token)
                    winner = game.check_winner(board2)
                    if winner is other_token:
                        if (len(available_moves) > 1):
                            try:
                                available_moves.remove(col)
                            except ValueError:
                                pass
                except AssertionError:
                    pass
                            
    for col in available_moves:
        board3 = board_copy(board)
        game.make_move(board3, col, other_token)
        winner = game.check_winner(board3)
        if winner is other_token:
            return col
        
    if board == [['.', '.', '.', '.', '.', '.'],
                 ['.', '.', '.', '.', '.', '.'],
                 ['.', '.', '.', '.', '.', '.'],
                 [other_token, token, other_token, token, other_token, token],
                 [other_token, token, other_token, token, other_token, '.'],
                 ['.', '.', '.', '.', '.', '.'],
                 ['.', '.', '.', '.', '.', '.']]:
        return 2
    
    if ((board[3][0] and board [4][0]) == token) and (2 in available_moves):
        return 2
    
    if 3 in available_moves:
        move = 3
    elif 4 in available_moves:
        move = 4
    elif 2 in available_moves:
        move = 2
    elif 5 in available_moves:
        move = 5
    elif 6 in available_moves:
        move = 6
    elif 1 in available_moves:
        move = 1
    elif 0 in available_moves:
        move = 0
    return move