antbot

BlitzMax Forums/BlitzMax Programming/antbot

Paul "Taiphoz"(Posted 2007) [#1]
File :: http://www.coreillusions.co.uk/games/antbot/antbot.rar

The file has all the media needed.

This is a wee thing I did months ago and just found it again, While playing with it today and adding a few things to it I found it doing strange things, and I am sure its my dodgy maths, maths isn't my strong point and being dyslexic I find it hard to track down maths problems.

So, here is the full source, and media.

What should be happening, is that each queen spawns some workers, they then go and gather some food, once the queen has enough food she either spawns another worker or a soldier antbot.

Its something with the angles cos if a target moves to the left of the ant targetting it, it gets all confused, or sometimes the ants just go in circles for no clear reason. lol very strange.

Anyway, the soldier ants, pick a target, and hunt it down, when in range they damage it then return to their queen.

Have a look, and thanks in advance for any help, I hope its something really simple, but given the age of this code and how messy it is, I fear it may need a full rewrite.




Who was John Galt?(Posted 2007) [#2]
Don't know if it makes any odds as I haven't run the code, but you have a repeated const. Hunting=worker=14.


H&K(Posted 2007) [#3]
Hi,

What font do you use for you IDE?

I would sudgest, if you havnet already the you look at useing Comic Sans MS, or if you need monospaced AnonymousTT. Both of these have been found to improve recognition.

Also you should try to find what colours most effect your shape recognition and (obviously) pick the ones that are best.
I found for me tha best to be, a charcol/slate background (Normaly rgb of 50 each), and pastal shades for the text (Normaly one of rgb at 255, and the other two not less than 128), this will normaly be different for different people, but either use your test results from your dyslexia tutor/modderator, or just by messing with it.

If you havent got an official diagnostic confamation/analysis of your dyslexia, I would suddgest that you do so, so as to gain the information above.


Paul "Taiphoz"(Posted 2007) [#4]
Nomen, that should matter its only a state checker, the onther one is used in a different way but I will check it just to be sure.


@H&K, it hits us all in different ways, I know people from uni that had colour trouble, I don't.


Paul "Taiphoz"(Posted 2007) [#5]
Just noticed, the probllem occurse when a bot is trying to target something on its right hand side. if its target is on the left if seeks to it fine, if its on the right if freaks out.. What the hell is up with that.


Mr.Meertens(Posted 2007) [#6]
Hi Yavin,

If you change:
self.tAngle = 360-ATan2(mx,my)
into:
self.tAngle=(360-ATan2(mx,my))Mod 360

the circling problem is fixed.
Fun program by the way.


Paul "Taiphoz"(Posted 2007) [#7]
can you explain that change for me..


H&K(Posted 2007) [#8]
I know people from uni that had colour trouble, I don't.
Its not a question of colour trouble, its a question of giving you the best chance of pattern reconistion. I not saying you might be bad at some colours, just that you may be better at others.
Even people without dyslexia will be better/worse at reading when presented with different colour combinations. In fact for differnt colours not to make a difference means that you do have a problem with colour, cos your pattern recognition is just as bad with all of them.
Anyone remember the Lightening Forth manual?


Paul "Taiphoz"(Posted 2007) [#9]
What I meant was that my Dyslexia hits me in other areas but I don't really have any issues with pattern recognition, and tbh the blitz default colour scheme is spot on for me, I always thought that Mark be dyslexic as well because of it.

For me Math is the main issue, My brain simply cant process numbers, and My spelling suffers as well with letters getting mixed up and words appearing in bodies of text that dont really exist lol. its funny some times. caused me loads of trouble at UNI when I had to give a talk.


Mr.Meertens(Posted 2007) [#10]
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.


Paul "Taiphoz"(Posted 2007) [#11]
@Mr.Mee.... Yeah lot of code in there that is not being used yet as I had planned to do a lot more with it when I started this yeas ago.

I think I will rewrite it and clean it up some.

Still had to add the ants leaving scent trails for danger and food so still goto do all of that.

Have a play with it let me know what you come up with. I like to see what others can do with it before I start to recode it as you guys might think of something cool that I havnt.