reset password
Author Message
emagsin
Posts: 4
Posted 17:46 Sep 28, 2012 |

So, the tutorial acknowledges the problem that some may have, but doesn't really offer a solution.

 

After Step 1, instead of the first ant turning East and then North into the enemy's territory, it stays within the base and oscillates back and forth behind the barrier.

 

Per the website:


If your bot's ants oscillated behind their barrier instead, it is probably due to the ordering of the ants in your loop. If the NW ant moves first it moves to the North of the SE ant, which can then only move East, South or West. Otherwise if the SE ant moves first it moves to the East of the NW ant, which can then only move South or West.

 

Now I've tried fiddling with the code and adding new methods and continuing with the tutorial, but the problem still hasn't fixed itself.  After finishing the tutorial, the game ends in a draw with six food pellets left. (Ideally, after the tutorial, all pellets should be eaten and there should be at least ten ants in the team)

 

Anyone have a similar problem/solution?

rabbott
Posts: 1649
Posted 19:12 Sep 28, 2012 |

As I'm sure you know, the solution involves changing the code. This is the sort of thing that comes up all the time in this problem: your own code doesn't produce the result you want. In this case it's not all your own code, but you know what I mean.

The challenge is to figure out why the ants act the way they do and then change the code so that they stop doing what you don't want them to do and start doing what you do want them to do.

This is always the programmer's challenge: why doesn't your code do what you want. Since it's your code, who better to answer that question but you! It's fine to discuss problems and issues, but ultimately, each person must take responsibility for what his/her code does and not treat it as a mystery. After all, you wrote it.

I don't mean the preceding to sound harsh. I simply want to take this opportunity to point out that one reason this is a difficult problem is that it produces these kinds of results very often. Your own code (or code that you have taken ownership of) doesn't do what you thought you wrote it to do. Yet you wrote it (or adopted it).  How can it be that it doesn't do what you said? Yet there it is.

The answer is that in this problem more than in most, your code interacts with its environment. With most of the code you have written in your career pretty much all you had to worry about was what the code itself did. In this problem you have to worry not only about what the code does but also about how the code changes its environment and how that change effects the objects that the code controls.

Last edited by rabbott at 19:49 Sep 28, 2012.