Sunday, July 7, 2013

BIG Update

It's been an intense two weeks on the project. There's so much stuff I'll have to bullet point it.


  • Planner is greedy, meaning it searches for any event that passes it's precondition and doesn't affect a currently in use state.
  • Cut down sizes of a lot of objects.
  • Created new map and scenario for demo.
    • Abstract prison, with locked doors, guards, keys etc.
    • Two sides of prison, with agents that all go towards same goal, and even help out each other now and then (well once for now...).
  • Worked on doors and other objects to make everything easier to edit and add to the map
  • OPTIMIZATIONS (took lots of time...)
    • Had planner store Default Actions instead of my event class which extends the default action class
      • My events contained information extraneous to the planner such as the behavior trees
      • Had to refactor a lot of code
      • Added an int to Default Action which corresponded to a unique Event.
    • Abstracted positions to just be a room number, and doors to be links between two rooms.
      • Allowed me not to track position of agents as they moved.
      • More importantly, took away need for constantly calling NacCanReach, an expensive Unity NavMeshAgent function
    • Changed my extension of the Default State class to use unsigned long bitmaps instead of string->int Dictionaries
      • This was the most difficult change of all
      • State has to keep track of every object and agents state in the world
      • For now state just includes two ulongs, one for the states of objects and agents, and one for the state of the rooms and what other rooms they can access.
      • Had to create all this power of 2 offsets, based on 1, the objects "number," and 2, the specific state's location on the bitmap.
        • For instance Person 3's "has key" state is mapped to 2^14 (where all they has key states go) * 2^3 (the person's number offset)
        • This got to be very complicated for certain states who's state were not binary (for instance, what other rooms a room has access to) and for retrieving and changing specific bits
        • Too many bitwise operations
      • Huge boost to memory performance
    • Changed which agents had the ability to perform which actions to create as few branches in the plan as possible
      • As much as possible, give each agent one option at each stage in the plan, so the planning tree does not grow exponentially
      • Actually the easiest change, but the biggest effect
      • Finally got both sides of map planning in tandem in just 2 seconds!
  • Added new trapping a guard event. Uses agents from both sides of map