I'm just looking for help with the pseudocode for my functions.
This is what I have so far:
data structure for position is 19x19 array of cells with three possible values. 0=empty, -1=black piece, 1=white piece
move parameter is passed by reference so the min and max functions have a score value as their main return, but also inherently return the move that equates to said score
move datatype has x and y members
max(position[][], depth, byref move)
if depth = _maxDepth_ return 0
max_score = -infinity
best_move = null
for each move in getLegalMoves(position)
if testForWin(position, 1, move) return 1
temp = min(getNewPosition(position, move), depth+1, move)
if temp > max_score
max_score = temp
best_move = move
min(position[][], depth, byref move)
if depth = _maxDepth_ return 0
min_score = infinity
best_move = null
for each move in getLegalMoves(position)
if testForWin(position, -1, move) return -1
temp = max(getNewPosition(position, depth, move), depth+1, move)
if temp < min_score
min_score = temp
best_move = move
getLegalMoves(byval position)
for each cell on board
if cell.value = 0 AND sum of absolute values of adjacent != 0
append this cell to legal_moves[]
return legal_moves[]
getNewPosition(position, depth, move)
position[move.x][move.y] = depth%2 ? 1 : -1
testForWin(position, moveType, move)
starting from (move.x, move.y) iterate to the left until you hit board edge or encounter a value of -1*moveType or have gone four to the left
then iterate to the right until you hit board edge or encounter value of -1 or have gone x to the right where x + how far you went to the left = 5
same for vertical and diagonals
I really have no idea if I'm approaching this right or if this will even work so any pointers as to problems with my logic or flow or byref vs. byval parameters etc. would be appreciated.