简体   繁体   中英

Creating Node for negamax/minimax for Reversi/Othello game

I write AI player for reversi game, and I decide to do it with NegaMax or MiniMax. Pseodocode:

function negamax(node, depth, α, β, color)
    if node is a terminal node or depth = 0
        return color * the heuristic value of node
    else
        foreach child of node
            val := -negamax(child, depth-1, -β, -α, -color)
            {the following if statement constitutes alpha-beta pruning}
            if val≥β
                return val
            if val≥α
                α:=val
        return α

But I need to sent Node to this function, how can I create this node? Like create Node with all possibles move for state, and then create child-nodes for everyone possible move in Node?

And if you can help with α, β values...

Node likely is meant to represent a single state. In games this is the state of the board (for Othello the placement of the pieces, whose move it is. etc.). Generally in games that use alpha/beta pruning, generating all the next states is possible, but generating all the states for all possible positions is not.

If you're using Java, then a Node object might have a method getChildren() to generate all possible moves from that state, themselves Node objects.

As for the α, β values, these are initialized at Integer.MIN_VALUE and Integer.MAX_VALUE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM