Skip to content
Julian Roth edited this page Nov 15, 2018 · 2 revisions

Four In A Row

An overview of Main.java


An overview of Board.java


An overview of Player.java and the children of the Player class


An overview of Minimax.java


Pseudo-code for minimax with alpha-beta pruning:

function alphabeta(node, depth, α, β, maximizingPlayer) is 
    if depth = 0 or node is a terminal node then 
        return the heuristic value of node
    if maximizingPlayer then 
        value := −∞
        for each child of node do
            value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
            α := max(α, value)
            if α ≥ β then 
                break (* β cut-off *) 
        return value 
    else 
        value := +∞ 
        for each child of node do 
            value := min(value, alphabeta(child, depth − 1, α, β, TRUE))
            β := min(β, value) 
            if α ≥ β then 
                break (* α cut-off *)
        return value 

source: Wikipedia: Alpha-beta pruning