The difference between the two is that the 2nd tAngle will always be a value between 1 and 360. In your turnant method you compare cAngle with tAngle. cAngle will wrap around and thus never greater than 360.
You have a method wrap angle, but it's called at the end of the update and useless, because you change the tAngle every update to new values. (if you move the call up two rows you have the same result as changing everything to the mod rule)
Yesterday I gave it a quick look. And now I see that it doesn't solve the problem completely. It does for state 14 (hunting) but state 2 (rtq) still suffer from the circle disease ;)
I also noticed you use a select switch in some state and defining some local vars (mx,my) in the case switch. You later use these vars to update tAngle. But because this happens outside of your select switch the values of mx and my are alway zero. I haven't changed it but maybe it makes a different ;)
When you use aTan2, you use aTan2(mx,my). If I press F1 on the command I get ATan2( y:double,x:double). If you change that the Ants will move but get stuck on the edge ;)
The program still has some redundant code, so a rewrite would be the best option.
Nevertheless I found your program a very useful example of a state machine. I will have a closer look at your code when I have fixed my pc at home.
You have a method wrap angle, but it's called at the end of the update and useless, because you change the tAngle every update to new values. (if you move the call up two rows you have the same result as changing everything to the mod rule)
Yesterday I gave it a quick look. And now I see that it doesn't solve the problem completely. It does for state 14 (hunting) but state 2 (rtq) still suffer from the circle disease ;)
I also noticed you use a select switch in some state and defining some local vars (mx,my) in the case switch. You later use these vars to update tAngle. But because this happens outside of your select switch the values of mx and my are alway zero. I haven't changed it but maybe it makes a different ;)
When you use aTan2, you use aTan2(mx,my). If I press F1 on the command I get ATan2( y:double,x:double). If you change that the Ants will move but get stuck on the edge ;)
The program still has some redundant code, so a rewrite would be the best option.
Nevertheless I found your program a very useful example of a state machine. I will have a closer look at your code when I have fixed my pc at home.