Monday 26 January 2015

Sprint Update 26.1.2015 - Fresh brains!

First full sprint of 2015 completed, and we definitely made quite a lot of progress in this one!






New brains for everyone…

The planning and research we did on goal-oriented action planning in the last sprint has paid off, and our new AI is now doing everything the old system did, but with less bugs, and better design that allows us to continue building more complicated behaviours for non-player characters in the game.

For anyone not familiar with GOAP, the idea is that we give the AI some information about the current state of the world, and some goals, and it will then on it’s own try to create a plan to fulfill that goal based on whatever actions it has available. This means that lots of the AI is now separated into individual actions which are easier to work with (as each action only deals with a very specific task), and we can easily add more and more actions for different (or even the same) purposes. By giving different selections of actions to different characters, we can create much more variation on how they decide to complete the goals they have.

The current actions and goals we have pretty much just do what the old AI was trying to do, but already it has some nice improvements. For example when chasing the player, the AI is now able to predict player movements slightly even after they loose direct sight of the player. So simply hiding behind a door or something is not going to do the trick any more if the guard clearly saw you doing it…

We also separated chasing the player and actually catching him into actions of their own, so we can easily add different ways the guards can trap the player if they don’t happen to have a taser available (or perhaps if they find it less work, or simply more amusing, to do something else instead).





Procedural SMS based on NPC personality

The other major new feature is that NPCs can now receive and generate (or ‘write’) their own text messages base on their personality. This means that essentially all the data being produced by a character is influenced by them as an individual, giving you the ability to collect it and build a profile on them to surveil their behaviours, guess or collect their passwords and security questions, and choose actions that will effect them based on who they are, as well as giving you the player a sense of looking in on the private lives of the NPCs walking around and unwittingly leaving a data trail.

This system is pretty interesting in how expandable it is, we still have loads of work to do on it and we already have plans for making it available to players to extend and it the messages and personalities of NPCs for modding and level design purposes.

We devved this while at indie co-working at the London Game Space at Loading Bar, and got some of our fellow Indies to input their personalities to the NPC to see what messages were generated with some pretty funny results. check out some of the screens we’ve tweeted out recently and if you are in the London Indies scene you will probably recognise a few personalities!

Watch this space, we are sure there a more interesting updates on this feature to come.

Shiny new DataPoints

Probably the smallest and quickest change in this sprint, any new data points created will now glow for a while. This makes it easier to track where new ones are being created, and thus also where the guards are located at the moment. With the increasing amount of data displayed and created after building our GPS tracking and the new SMS systems we definitely needed something to make the new data points easier to spot.

New animation & movement setup

With their new brains, our NPCs also have new nervous system controlling their muscles. Or, in this case, new scripts to deal with Mecanim character animation, NavMesh navigation, and rigidbody physics in a way that allows us to get the best from all three systems while preventing them from confusing each other. It seems to work fine, the test character is moving around free from the sliding footstep problem our old movement script was having, and they also keep track of where they are and where they should be heading even if some collision or unscripted occurrence moves them around.

Automated testing tools

Testing the functioning of AI after certain events, or how often a proceduarally generated text message is making it to the phone of a given NPC, can be a tedious and on a occasion impossible thing to test for in the general editor while working on the game….  And so, with a little help from Unity demi-god and long term collaborator Richard Fine aka @SuperPig, we setup 'Automated Testing’ using the Unity Test Tools framework.

The Unity test tools are set up to facilitate running a build (or even multiple builds) automatically and at waay faster than real time speeds, only responding to certain occurences in the game which you have periviously specified. In simpler terms if you have soemthing you want to test at the end of a level, instead of booting up the game in editor, spawning in a developer cheat to get close to your objective and then testing the action yourself to see if the code you just wrote works, you just specify the action you want to test in code in a test scene, press 'Go’ and Test Tools will essentially tell you if the thing you have specifeid at the end of the level passes or fails to occur. If you imagine whanting to test hundreds of occurences of a thing throughout the game in various places in a large level (or even multiple levels) then this can pretty rapidly speed up and improve your testing times as well as your results. This is called Integration testing.

All you do set it up is add Unity Testing Tools from the Asset store, create a new scene that contains the components and objects you want to test and all their dependencies, and then create testable generic functions that specify what outcomes should define a passing or failing of the test.

In our instance we set up a basic integration test scene for the SMS creator and all its related code and components and used it to check that text messages were being received and generated by NPC’s based on their personality. As well as being used to test large and time consuming processes in the game, integration testing and Test Tools can also be used to facilitate test driven development. This is where you specify an outcome you wish to develop for a feature before you have written the code to get there. This then will fail until you have all the code working to deliver the outcome you specified, at which point it passes and you have developed that feature, bada-bing! Done!

It’s a great way of disciplining how you organise your code and keeps you from waning or swapping between features until they are useable in a build (not just having no compile errors!! :P). Very handy for sprint based or agile development where being able to play a feature in game is a defining factor on completion of a sprint and it’s tasks (even if not always strictly true).

Although it’s a bit of work to set up in the first place your integration test scene can then be used to eventually move onto other data features testing (or whatever design component you have chosen to specify), so it pretty much pays for the time investment the first time you run it on a long process but once you get into the swing of thing you have an automated test bed for most features already set up and ready to roll as soon as you start work on them. If you are a Unity dev making a decent size game and not using this feature yet, you should definitely check it out.

Anything else?

Hmm.. well that was a pretty long and technical end to the update post, and no pretty pictures for integration testing I’m afraid! If you are around the East London area tomorrow (Tues 27th Jan) Pontus and I have been invited to speak at Cybersalon for their event 'The Future of the Darknet’ event details can be found here:

http://www.cybersalon.org/darknet/

Come on down and see us! Otherwise we’ll see you here at the end of next Sprint!


No comments: