Game Design and Artificial Intelligence - Bournemouth University
Game Design and Artificial Intelligence - Bournemouth University
Game Design and Artificial Intelligence - Bournemouth University
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Game</strong> <strong>Design</strong> <strong>and</strong> <strong>Artificial</strong> <strong>Intelligence</strong><br />
David Hopkins<br />
fig 2.3 – The bridge of the ship with the player character <strong>and</strong> the AI pilot<br />
Space Combat<br />
The space Combat was where most effort was based during the production of this project. For the<br />
demo, all though there was not enough time to implement a three dimensional version, it was<br />
possible to work on a two dimensional approach, with an x <strong>and</strong> y axis. Three attempts were made at<br />
producing the AI for the ships. The first experiment was creating a ship that would follow a target<br />
around. This was done by calculating the distance between the ship <strong>and</strong> the target in both x <strong>and</strong> y<br />
axis, calculating the angle between them <strong>and</strong> adding a velocity based on the angle. Much of this<br />
was taken from my previous programming project from last year, as this used the same theory to<br />
have an object always look towards a target. However there was a drawback with this. The ships<br />
could only rotate 360 degrees. Once the angle reached over 360 degrees, the object would have to<br />
rotate all the way round the other way as the object believes the angle to be a small value (as the<br />
value over 360 would then switch to 0). This method required some tweaking which would allow<br />
the object to follow an object by rotating around the quickest way. The way this was solved, was<br />
through working out the difference between the current ship rotation <strong>and</strong> the desired angle. If this<br />
difference is less than <strong>and</strong> absolute value of 180 degrees, the ship can rotate based on whether angle<br />
is smaller or larger. However if the difference is bigger than 180, then we have to reverse this<br />
situation as the target has gone full circle. This took a while to discover, but it is fairly effective.<br />
if((rotationangle)>180)<br />
{<br />
if((rotationangle)>0)<br />
rotation+=(70.0*TIMER);<br />
}<br />
if((rotationangle)