Expansion via Recursion
function expand-node(boardptr, nextsquare,xoro){
newboard := copy(boardptr)
newboard.config[nextsquare] := xoro
insert(newboard,boardptr.nextply)
expand-node(boardptr,nextopen(newboard),xoro)
if winner(newboard) then newboard.winfor := xoro
else if xoro = x then switch=o else switch=x
expand-node(newboard,firstopen(newboard),switch)}
gameroot := alloc(boardptr)
expand-node(gameroot,1,x)}