• Finite State Machines


    This is a learning process!

    Most of my programming experience stems from Web development, although I have been dabbling in hardware/electrical engineering in the past few years. In web development, I rely heavily on automated tests to guarantee that my code works, and sometimes I even practice Test Driven Development. Game development is a relatively new area of focus for me, and therefore much of my experience has been exploratory in nature. Whereas in web development, the various modules and components that I make tend to be exercised in specific, isolated scenarios that are easy to test at the boundaries, in the sort of game I am making, there are a massive number of possible interactions between the various objects and systems and no clear way to test them in an automated way.

    Finite State Machines to the rescue!

    As I started to add more creatures, plants, and their respective behaviors to Into the Thicket, I began encountering strange, hard to track-down bugs (no pun intended) such as ants getting stuck in weird places, attempting to cut down a blade of grass when they already have one held in their mouths, or staying engaged in combat indefinitely with no victor or loser. I realized the ony way to solve the issue was to fall back on a technique I've used to great effect in my hardware projects, The Finite State Machine. Instead of trying to manage all the individual creature's decisions based off the various parameters of their internal state, I modeled each creature/plant as an FSM. What this essentially means is that there are a finite number of specific states that each of the creatures can exist in at any given moment in time, and so all those various internal attributes only matter in their deicision making process while they are in specific pertinent states.

    Ant Finite State Machine Diagram
    Ant Finite State Machine Diagram

    Grasshopper Finite State Machine Diagram
    Grasshopper Finite State Machine Diagram

    These State Machine diagrams will evolve over time as additional behaviors are added or changed. Here are the links if you are interested in checking them out:

    Ant Finite State Machine Diagram

    Grasshopper Finite State Machine Diagram

    Mushroom Finite State Machine Diagram

    A (sorta) bug-free experience

    It was a non-trivial amount of work to refactor all the systems to use this new architecture, but the benefits were realized immediately. Many of the bugs, especially surrounding ant combat, disappeared overnight and the simulation feels much more stable overall. I purposely exported this version with the targeting system and Foraging/Attack radiuses visualized so you can more easily take in the complexity of the underlying simulation.

    Ant debugging visualizations
    Ant debugging visualizations

    Debugging visualizations explained

    Each creature with the Targeting behavior gets a targeting arrow that extends between it and it's target. Ants have two line of sight radii. The first, larger radius is the Ant's foraging radius. The ant can only target food if it is within this line of sight. The second, smaller radius represents the Ant's attack radius. If an enemy ant appears within this radius, so long as the ant is not already delivering food back to its Ant Hill, the ant will prioritize meeting the threat with force. When an Ant decides to 'charge' an enemy, its attack radius turns yellow. When an ant collides with an enemy ant, the attack radius turns red, to indicate that combat has begun. When combat has finished, the Ant's attack radius turns white to indicate it has returned to the 'idle' state, and the Ant picks a new target. When an Ant has a viable food source in its line of sight that is not already targeted by a member of its team, it selects it as its target, and the arrow turns green to indicate that the Ant is on its way to cut down and gather that food source. Once an Ant has successfully acquired a viable food source, the arrow turns yellow to indicate that it is delivering it back to the Ant Hill. In the event that an Ant has no viable food source or enemy in its line of sight, it picks a random location on the map to scout. If, during foragin the Ant comes across a viable food source, it selects that food as its target and the cycle continues. Otherwise, if the ant gets all the way to its foraging target without coming across food or an enemy, it selects another random foraging target and starts looking again.

  • About Into the Thicket

    What is Into the Thicket?

    Short clip of Into the Thicket
    Short clip of Into the Thicket

    Into the Thicket is a forest simulation and zen-management game being made by me, Nick Camillo. It is the second, more ambitious iteration of an interactive art piece that I made in 2012.The grand plan is still in flux, but the overarching concept is to tend to the denizens of a unique, digital thicket as you grow a tree over a period of time. Sort of like a tamagotchi, except instead of looking after the health of a single creature, you're trying to optimize for the greater good of the ecosystem.

    Click here to try any of the versions

    What's in the game now?

    Flora 🌳 🌱 🌲 🌿 ☘️

    Grasses 🌾

    • grow on collision with sunlight
    • eventually flower and spread seed
    • provide food for ants

    Mushrooms 🍄

    • grow in absence of light
    • eventually spread spores at maturity
    • provide food for Ants

    Fauna 🐛 🐝 🐞 🐸 🦆

    Ants 🐜

    • seek food for their colony
    • defend their colony from other colonies
    • dispose of dead
    • provide food for Grasshoppers

    Grasshoppers 🦗

    • seek food
    • keep Ant population in check


    Rocks 🥔

    • block Ant line of sight and pathing
    • cause light to refract

    Acorns 🌰

    • block Ant line of sight and pathing
    • cause light to refract

    What's next on the agenda?

    • Hydration/Watering System
    • Day/Night cycle
  • Humble Beginnings


    Ever get hit by a hurricane, twice?

    Rewind back to late October 2012. I'm flying all over the country on Microsoft's dime, fulfilling boring, businessy agendas by day and writing or performing folk music by night. I've just finished a required visit to the home base in Charlotte, NC and just like all the other non-locals, I was trying to get the hell out of dodge before Hurricane Sandy mucked up my plans. Unfortunately, we were all stranded. Stuck in the airport until the weather cleared. There were no available seats, but luckily enough, I found an open spot against a wall next to an electrical outlet.

    Animation of Hurricane Sandy

    Eighteen hours without internet access

    I had recently bought the excellent game-making tool Construct 2 (now cloud-based Construct3) and had been experimenting with tutorials while building out a point-and-click adventure game about an endearing Gnome character named Pan. All I wanted to do was work on that game, but alas, I was stuck on some complicated feature that required research to resolve. And seeing as though the internet at the airport ranged between non-existant to unusable, I decided to make something different entirely.

    Animation of Pan the gnome in the wind
    an early render of Pan, my gnome character

    Simulators are cool 😎

    I had just recently learned about Conways Game of Life, a fascinating zero player game whose progression is determined solely by the initial state of the game as it plays out according to the rules. I've always been fascinated by the concept of emergent gameplay and the idea of a player discovering unintended scenarios that arised due to a strange and interesting combination of rules and systems. I wanted to explore these notions in my own game.

    Animation of Gospers Gliders Game of Life automata
    An animation of Gospers Gliders, a cellular automaton discovered in Conway's Game of Life

    Plants are cool too 🌱 🌿 🌳

    At this point in my life, I was pretty obsessed with plants. I'd spent countless hours watching videos of plant-growth timelapse videos. I'd seen Microcosmos and the Plants episode of BBC's Life dozens of times. I'd even produced time-lapses of my own. So it shouldn't be much of a surprise that it dawned on me: A plant growing simulator! I mean, how many games have you heard of where you get to be a plant, right?

    Time-lapse animation of a sapling sprouting Time-lapse animation of a dandelion flowering
    Time-lapse of a sapling sprouting

    A Digital Terrarium

    This early version was extremely simple. It was two-dimensional, there was only a single plane on which the various plants could grow. I had to re-learn some basic trigonometry in order to make the Sun and Moon orbits, and I went with a typical bullet-hell-style balls to represent photons. When photons hit grasses or plants, they would grow until they reached maturity, at which point they would flower, spawn a new instance or two elsewhere on the map, and die. Mushrooms, on the other hand, shrunk on contact with light and only grew or spawned in prolonged absense of light. The player took control of a sapling who had just emerged from a fallen seed, and through very basic left-or-right controls, had to collect enough light to be able to grow, at which point the camera would zoom out to reflect your plant's increasing size.

    Short clip of the original Into the Thicket
    Short clip of the original Into the Thicket

    Thanks, Hurricane Sandy

    18 sleepless hours later I boarded my flight to CT with a stiff back and a rudimentary forest simulation. This was before I became a software engineer, so it was a spaghetti-maze of repetetive, nightmare inducing pseudo-code. But it worked. I finally got home up in Connecticut, just in time for Hurricane Sandy to say hello again. So I hunkered down and added a brief, cinematic introduction with some original music to hopefully add some flavor to the experience. If you're interested, you can play the original Into the Thicket here.