This can be moved inside the loop. No need for the extra neighbors array? Just loop through the NEIGHBORS[lastMove][i]...