def eval(player, board): count = 0 opp = opponent(player) for y in range(len(board)): for x in range(len(board[0])): if board[y][x] == player: count += r4.findLength(x, y, board) elif board[y][x] == opp: count -= r4.findLength(x, y, board) return count
def eval2(player, board): count = 0 opp = opponent(player) for x in range(len(board[0])): y = r4.findMinRow(x, board) if not r4.isValid(x, y, board): continue r4.setLoc(x, y, player, board) length = r4.findLength(x, y, board) if length >= 4: count += 1 elif r4.isValid(x, y+1, board): r4.setLoc(x, y+1, opp, board) length = r4.findLength(x, y+1, board) if length >= 4: count -= 1 r4.setLoc(x, y+1, 0, board) r4.setLoc(x, y, 0, board) return count