# BattleCity AI - help needed

## Recommended Posts

TheDmD    184
Hello, Can somebode explain me, how tanks in BattleCity games are driven? I have no experience with AI, so I need clear explanation. Thanks for help (if any)

##### Share on other sites
Alrecenk    400
The old nintendo game? From what I've seen of it I'd guess they are pretty random. The tank picks a direction it can travel in at random with a greater chance of travelling towards the flag then away from it and then moves for a set period of time or until it hits a wall while firing periodically with some randomness involved. At most there could be a finite state machine behind it, but I wouldn't expect more than a few simple rules.

##### Share on other sites
TheDmD    184
Yes, exacly that game. :)
I think, there is no (advanced) state machine.
Do you think, that guarante me that tank will move to base (sooner or leater)?

Sorry for my english, my native language is C++ ;)

##### Share on other sites
Timkin    864
Okay, some funky hand-wavy (but mathematically justifiable) fun...

It's not too hard to show that if the tanks rotation is biased (even only slightly) in turning toward the base rather than away from it and assuming that it's forward movement was not very large between rotations, then we can expect the tank to arrive at the base eventually.

Why is this so?

Consider that rotations toward or away from the base are equivalent to left or right radial steps once the tank moves. We can ignore the tangential component of movement and consider just the distribution of position radially. If the probability of turning toward the base is higher than that for turning away, then the conditional distribution for the next radial position given the current is weighted toward the base. The resulting process dictating radial positions will be ergodic and will have a stationary distribution that is a point mass at r=0 for t=infinity. Prior to this, the expected position of the tank at some time T seconds from now will always be between the tanks current position and the base (so it's a bounded semi-martingale iirc). Given the probabilities for turning toward or away from the base we can compute lots of nice properties of the expectation as a function of time.

So what does all this gobbledy-gook mean? It means that if you take the very simple strategy of turning toward the base with probability p and away from the base with probability 1-p, such that p > 1-p, then you can rest assured that the tank will eventually arrive at the base (but the universe may end first if you choose p~=q. No alternative complex strategy is required.

Cheers,

Timkin