Thursday 7 April 2016

AI Implementation

Following my last post; Reading: 'Artificial Intelligence for Games', and AI Planning, I have now started attempting the implementation of the pseudo-code created.

To start with, I have now given units a tile variable, allowing them to know what tile they are on specifically, at all time. I had done this initially for the IndexOf value of the node they were on, as specified in my pseudo-code from my previous post:


This is the code that has been implemented so far. The main issue I have been facing with this, is incorrect values for the path lengths:

I added a simple input, where pressing 'z' will give me Path Count.
As seen at the bottom, '22' was the value returned for the topmost User Unit.

For the User Unit to the right, '6' was the value returned for the path count.
Finally, '4' was the value returned for the left User Unit
The issue is, the results generated by the current AI code seem very far away from this (With the if statement disabled for clarity):
As can be seen, one loop has all path counts returning as '36', with every loop afterwards returning with a value of '6'. All Grid Positions shown are correct.
From what I am able to understand, once initial loop has been made, the target is left on the right-hand User Unit. While the names and grid positions are cycling through, there seems to be an issue with the target itself, though I cannot see any issue within the code, other than perhaps the fact that the change in positioning is not able to keep up with the loop it is in.

With this issue at hand, I will have a discussion with my lecturer, to clarify that my current code and pseudo-code is viable, and to find out if the issue I am facing is efficiency issues, or incorrect code.

No comments:

Post a Comment