Ronan Murphy :: loser.py

This bot has played 1980 games (13 wins / 0 draws / 1967 losses).

Play against this bot as X or as O.

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

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

...and these bots have done worst

Bot P W D L Points Size From beginner One hit wonder Goldfish
Matt Wheeler : : smol.py 10 10 0 0 10 77 False True True
Jordan Banting : : trololololol.py (v1) 10 10 0 0 10 402 False False True
Tom Campbell : : winblockprevent.py (v5) 10 10 0 0 10 321 False False True
Martijn Pieters : : zopatista.py (v9) 10 10 0 0 10 2649 False False False
James Campbell : : horrible.py (v4) 10 5 0 5 0 246 False False True

All standings against loser.py

The code

      
import copy

from botany_connectfour import game


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

    for move in available_moves:
        future_board = copy.deepcopy(board)
        game.make_move(future_board, move, token)
        if game.check_winner(future_board) is None:
            non_winning_moves.add(move)

    # Pick the col furthest away from the middle.
    prefered_move_order = [0, 6, 1, 5, 2, 4, 3]
    for move in prefered_move_order:
        if move in non_winning_moves:
            return move

    # If we are ever forced into a winning position.
    return available_moves[0]