Quote (carteblanche @ Feb 29 2016 09:39pm)
i dont think anyone's interested in playing reversi to figure out what you're doing.
if it's only 8 spots, why not hard code them?
row-1 col - 1; row-1 col; row-1 col+1
row col-1; row col+1
row+1 col - 1; row+1 col; row+1 col+1
make sure to check boundaries in case you're at an end/corner
this is what i was thinking off using an m x n matrix, piece placed at x,y; pseudo/python code, hopefully I didn't reverse the logic anywhere
vertical checking:
for i from 0 to m:
if i !=x
checkpiece(i,y)
horizontal checking
for i from 0 to n:
if i != y:
checkpiece(x,i)
negative slope diagonal checking
starty = y
while x > 0 and y > 0:
x = x - 1
y = y - 1
for i from 0 to n:
if i !=starty:
checkpiece(x,y)
positive slope diagonal checking
starty = y
while x < m and y > 0:
x = x + 1
y = y - 1
for i from 0 to n:
if i != starty:
checkpiece(x,y)