Welcome Distraction: Serin’s Creed

Weekly Updates 23 and 24 were spent on a spin-off idea for Victis.

In the small game development studio I work on, I lobbied for what we call “Free Friday” where, in every first Friday of every month, for the whole of that Friday, we’re allowed to make whatever videogame concoctions we can think of.

This is our excuse to make time doing those crazy ideas we get from time to time.

This is also to de-stress (as I like to call it “detoxifying”) from being full of client work. That is, work where we create a videogame for a client, per her/his instructions, leaving little room for creative ideas.

The catch with this Free Friday, is we have to start with a blank slate every time, and make sure we have something presentable at the end of the day. Think of it as a short informal game jam.

So for the November Free Friday I thought of making this idea I had one time before I went to bed:

“Damnit I want to play Assassin’s Creed right now on my Android tablet!”

That’s pretty much the basic gist of it. I wasn’t able to have much by the end of the Free Friday so I took the weekend and the weekend after that continuing on it.

Here’s what I’ve ended up with so far:

I’ve detailed more of it in my personal blog here: Battle Maiden Part 1

How is this related to Victis

The player character in that little experiment is a Battle Maiden.

I wanted Victis to draw (loosely) on Überwald-esque dark fantasy, and that included gypsies.

Through some athletic feats of cognition, my train of thought arrived at pistol-weilding, dancing, acrobatic gypsies, that right now I’m calling “Battle Maidens” until I figure out a better name.

_2012-11-25_12-38-34 serin model

The idea of acrobatic, one-man army, free-flowing gameplay that Assassin’s Creed and Batman: Arkham Asylum had, fit well with Battle Maidens, so that’s the graphics I used for this Free Friday game.

_2012-11-28_01-19-56 pose

W.U. 11: Behaviour Tree Traversal Display

Here’s a video where the A.I.’s behaviour tree traversal is inspected. I decided against watching a traversal as it happens because of performance reasons and instead, the game records traversals and you can watch them after they are recorded.

W.U. 10: Basic Attack AI

Here I have the enemy A.I. spamming the Lunge attack. UPDATE (2012Aug18 1540 PHT): It turns out my enemy A.I. was erroneously allowing the enemies to Lunge even when they didn’t have enough stamina points to do so. This has been fixed.

One thing to note was that it was starting to become a pixel hunting process for me to get the proper place to move to for an attack, as I suspected. This was why I wanted to make an attack preview where you see a ‘ghost’ of your unit doing the attack before you confirm the command. The ghost’s attack would highlight which units will get hit from the attack.

I also need a better stamina cost display.

Now, about the A.I., here’s the behaviour tree used for the enemies in the video:

It goes basically like this:

  1. Retreat if I need to
  2. Find nearest enemy
  3. Check if I still have enough stamina to get near him and attack
  4. Do the actual attack if I can
  5. Just close in if I can’t move and attack in the same turn

(I really wouldn’t need to add that additional check in the third step because of the way behaviour trees work. But it’s there because I plan on adding more to the tree.)

One thing I did not anticipate the A.I. to do, was that after they attack, they spend time backtracking to the proper range to do the lunge attack, so they’d be in the right position come their next turn. I was surprised that the A.I. was that clever, and yet, all it did was follow the instructions I gave it. And there it was in step no. 5 (i.e. close in if I can’t attack yet). Its just that I didn’t realize it would also do that immediately after an attack.


As for the behaviour tree editor, I was thinking of making the display look more like a folder layout, given the cramped space it needs to be shown on.

Here’s how that kinda looks like:

And here’s how my initial trial on the code for that looks like:

The purple, stretched hexagons are selectors, while the large rounded boxes are sequences. Sequences are allowed to have different colors for easier recognition.

Selectors arrange their children vertically, and sequences arrange theirs horizontally.

The white hexagons are conditions, while the white boxes are actions.

Watching Traversals

With my goals for modding support, I want to be able to show a behaviour tree in-game, so I made sure to use plain GUI code and not EditorGUI. With that I can show tree traversals as they happen. This is meant for debugging.

Stamina Cost Check Hack

The “CanLungeNow?” is a special (i.e. hack) type of sequence that I was forced to make. It basically accumulates the stamina cost of its children actions and returns failure if the A.I. agent (the unit) does not have enough stamina to do all those actions. I’m in the process of redoing it with decorators instead.

Static Tree

I designed my trees so that multiple agents can traverse one tree simultaneously. This means I can have only one tree that powers the A.I. of multiple units. While my game is turn-based and wouldn’t need such a feature, I may, however, add squadron units who will move and act together (goblin horde units).

This means nodes in the tree do not keep information themselves. Whenever they want to store information, they store it in the A.I. agent. If a node returns `Running`, it stores that state in the agent, not in the tree. Its stored in a hashtable, so they can put anything they want.

If a leaf node doesn’t have parameters, it might as well be a static class! If it does have parameters, those are most likely never changed during runtime. There could be a rare case for a need of an action that edits the tree it is in (self-learning A.I.?).

Flattening A Tree

Using Mono’s dynamic compilation features (allowing code to compile code), I can convert a behaviour tree from what it is right now, a bunch of classes arranged in a tree, to just one class with selectors and sequences converted to a bunch of nested if-else-if chains.

Most likely the leaf nodes (actions and conditions) need to stay as classes, but at least tree traversal will surely be faster, because there is no tree to traverse anymore; traversal is hardcoded for the most part. This is most likely what AngryAnt’s Behave library does as well.

W.U. 9: Retreat Behaviour

(Finally gotten around to making my screen recorder work at tolerable speeds. The sound also works though its really just recording from a microphone. Its also registering properly as 720 HD on YouTube now.)

Here is a demo video of the retreat behaviour, although it takes quite a while (i.e. multiple turns) until they figure out where to really go. I suspect once I start using influence maps this will work better.

W.U. 6: Melee Damaging

Check the video. The attacks now damage units. You’ll see the dummy red box has its health reduced when taking hits.

Its not quite visible in the video but I’ve also added swoosh trails on the weapon when attacking. Continue reading

W.U. 4: Melee Attack Crunch Time

With 6 hours 4 hours to go before the meeting, I’ve made an initial test for melee attacks. Since I don’t have any screen recording software at the moment, here is a recording from my tablet:

(Next, time, I’ll rummage through this.)

And here I’ve still yet to explain what those rings are when you attack. I don’t have time to make a diagram right now, but basically, each ring denotes one type of attack.

The smaller ring is for weak, fast, and short-range melee attacks.

The outer ring is, as demonstrated, for farther, more powerful melee attacks.

I’m taking cue from fighting games where you have varying degrees of attacks: maybe a light punch, medium punch, and heavy punch. A light punch makes you dash forward only slightly, while (generally) a heavy punch makes you dash forward a lot more.

Likewise in fighting games, enemies that get hit by melee here will receive pushback.