I'm developing an algorithm for the game of checkers and I came across a problem, when one piece eats the other, where I need to know the position of the piece that was eaten. According to the image and code below, knowing the value of a
which is the current position of the part and c
the future position, I need to find out the value of b
, which is the position of the part food, leading in the case of a - c = 7
, then b
is equal or a - 3
or a - 4
or if a - c = 9
, then b
is equal or a - 4
or a - 5
. How can I find out the value of b
?
if(a-c==7){if(a-3==b){}elseif(a-4==b){}}elseif(a-c==9){if(a-4==b){}elseif(a-5==b){}}