Tuesday, April 19, 2011

Huzzah!

Prior to my beta review, I had been struggling to understand how the agent behavior tree would direct changes in the agent's path.  Feedback from my beta review helped to clarify this.  The behavior tree will simply change the edge weights in the graph representation of the world.  My agent will recalculate its path every frame to react to these weight changes.

The first step in implementing this design is to have my agent recalculate its path every frame.  At first, I ran into some memory issues.. eek.


I resolved this by revising my pathfinder code.  Instead of returning the entire path, the pathfinder function now only returns the next node in the path.  This is sufficient since the path will be recalculated every frame (so returning the entire path is excessive).  Out of memory error fixed.

I still had to tackle my bug from my previous post, where the agent would stop before arriving at the target.  I identified the bug in my graph representation, where I was handling obstacle corners incorrectly.  I was creating a diagonal edge around a corner when I shouldn't have.  I fixed this bug, and huzzah!  See the video to watch my agent arrive at its target location.  (Again, the non-smooth movement is an issue with the recording's frame rate.)

Sunday, April 17, 2011

Path Following!

Can finally see the agent following the path calculated by A*!  The frame rate of the recording isn't great, but imagine the agent moving smoothly :)

One more bug: The agent is stopping before it arrives at the target, which is indicated by the small pink square.

Thursday, April 14, 2011

Unity Woes

I have been having trouble understanding how access of variables between scripts works in Unity.  I thought I knew how, but after much trial and error, I am still getting errors.  My pathfinding code is contained in one script, and my agent behavior code is contained in another.  Because of this obstacle, I have been unable to have my agent respond to the path calculated by my pathfinding code.

For example, in the screenshot below, the console shows a path count and the index.  I want the index to initialize to 1 less than the path count, which it currently is not doing.


I have already read a lot of Unity manuals and tutorials, but I suppose I need to read some more...

Saturday, April 9, 2011

Some Videos

The first video shows my project implementing the Roomba behavior tree.


The second video shows in the Unity console that my project correctly creates a graph representation of the world and calculates a path from a starting to end node. The position of these nodes and the edge costs are specified in the bottom right corner.

Thursday, April 7, 2011

A* and Unity

This week I had my beta review with Joe and Professor Badler. The review was extremely helpful in confirming my approach thus far and in generating ideas for how to get past some of the road blocks I am facing. Another point of feedback was to post to my blog more frequently -- even if I do not have a result to show, it's important to share and discuss the problems I am trying to work through.

At my beta review, I showed my progress since the alpha review:
- A* pathfinding implemented in C++. I am more familiar with C++ than C#, so I wanted to focus on implementing the logic of the algorithm rather than struggling with syntax.
- Graph creation in Unity. I needed a graph representation of the nodes and their neighbors in Unity before I could implement pathfinding. Each node has 8 neighbors (since my map is a square grid). I spent a lot of time here reading more about Unity and C#.
- A* pathfinding in Unity. I can specify start and end nodes and the code will generate the correct path. I am still trying to understand how Unity's physics engine syntax works, so I am still working to have my agent respond correctly to the paths generated. This will be my major task for the week.

I plan to have my behavior tree dynamically recalculate weights on the graph to influence the paths generated by the A* algorithm. Because I will be making constant calls to A*, I want to go over my code again and try to make it as efficient as possible.

Friday, April 1, 2011

Integration

This week I've been working to integrate my A* code with Unity in preparation for beta reviews.  Still have some polishing to do, videos to come soon!

Thursday, March 24, 2011

Pathfinding

This week I finished up the A* algorithm. Now that I have basic pathfinding implemented, I'd like to integrate it with Unity so that I can give an agent a target destination and have it move to the target using the calculated path. Right now, the implementation assumes that obstacles are not moving, which of course is an unrealistic assumption and an area that I will need to revisit later. Another next step will be to code a basic AI for "wandering" enemy movement.

As far as self evaluation goes, I feel that these past few weeks have been more difficult in terms of balancing senior design with my other classes. I felt that my alpha review went well and that my work earlier in the semester helped me build a strong foundation for my project. Now I just need to set aside more time to actually coding and implementing my framework. It seems sometimes that the deeper I get into the project, the more tasks I discover and need to add to my to do list (such as basic AI for enemies).

Current task list:
- Integrate pathfinding with Unity
- Enemy AI for wandering movement
- Visibility algorithm
- Updating A* for moving enemies
- Implement behaviors

Needless to say, I have a lot of hard work ahead of me! The self evaluation was helpful in recognizing this--thanks Joe!