Gamejam (for IMT2581 Rapid Prototyping course at NTNU Gjøvik) in collaboration with Aksel Hjerpbakk. A project where we explored the possibilities of using Unity’s finite-state-machine to create a simulated flourishing world consisting of agents capable of surviving in this world through the AI we created for them.

Repository can be reached at: https://gitlab.com/avokadoen/gamejamautomation

Some more information from a project report can be seen below:

Prototyping Report

Project date: 19. October 2018 - 21. October 2018

Development Environment:

  • Unity
  • Gitlab w/LFS

Description

Our project was an attempt to create a thriving simulated world using agents that were capable of sustaining through action without interference from any human. Some limitations were set to the agents like them needing sleep and food. What food they can eat is also defined. Some can eat meat from killed prey, while others eat plants or both. The world is generated based on a seed and there are three different tiles that can spawn. Green means grass, which can again spawn fruit or trees. Brown means dirt and was planned to be capable of transforming into grass over time. Grey means rock and has no properties to speak of. All objects in the scene are PhysicalObjects, which we have made for them to interact with each other depending on their durability and also density. So for instance stone would have a higher density and durability than a tree, thus it would tackle collisions and “damage” more than a tree. It would also inflict more damage on other objects with less density. This is also what affects the way combat works for our agents, they try to impact a force by ramming into their target and thus it will take damage as a PhysicalObject. More dense agents will inflict more damage on less dense targets.

We were also planning a mating feature. If an agent was well fed, it should have roamed the world looking for a mate. This would result in a new agent being created with morphed properties based on the parents. This would also mean that the world would be more likely to be fully sustainable as new agents would spawn. We would also see a proliferation of good traits in the agents after a certain number of generations.

My raw personal notes

Contribution

First day me and Aksel did a lot of pair programming and also some planning on how to approach this AI we wanted to make. Initially we wanted to go for some kind of hybrid between A* and “Minimax” when it came to what decisions to make. We worked a lot on how this algorithm would work on the first day.

Second day we ended up seeing that the idea with the A* hybrid would be pretty hard to work as we intended, and probably would end up taking way more time than we had for this jam. So we scrapped the idea, and went for a state machine AI instead. I also did some world generation work this day, and some work on spawnables that could drop other items. Went for some easy ways to generate a simple landscape with “biomes” (grass/dirt/stone) as that did suit our needs for this project. Also made it so this worked with a seed so we could always reproduce the same generations. Furthermore we did some pair-programming on the state machine, as that is the main part we wanted to work on, and was our main goal with this jam. We were struggling a lot with food not being found properly by our agents, and was messing around with this bug for a while. After a lot of debugging we found out that the raycast towards the model of the food they were supposed to eat, didn’t hit the model properly. This was due to the model’s properties and how the pivot point of it worked. (Model was made from Probuilder) However we ended up just making it so the food was small boxes instead of a round ball, and then the problem was gone, raycasts worked again.

Last day was mainly pair-programming more on the state-machine and making things work and act more “dynamically”. So that plant eaters would only eat plants, and sleep when they got tired, and so on. Also we worked on combat between agents that eat meat, so they would be able to kill each other off to eat each-other. I also did some minor generation work this day, mostly spawning agents in the world space, and giving them random initial values, so that they would all act differently in the world. Some would be quicker than others, they would have different metabolisms (causing some to eat more, some to eat less).

Reflection

The good
  1. First time trying to make a somewhat reactive AI - interesting to approach and try to deal with this problem. As there are so many ways to approach this problem, it is fun to have tried it out in one approach.
  2. Good schedule for work and sleep - Felt that the work/sleep management went pretty well. Didn’t stay up way too late working, and also got to working at decent times in the morning.
  3. Working with our PhysicalObject component - as we use this component in our game project in the Game Programming course, it was nice to implement this into a different environment and try to work more with it, to see how it would affect the world and how things interact.
  4. Trying to make AI can be really fun and interesting - When making the AI, we have had a lot of fun doing so. As what can be an initial thought and expectation of how some interaction will work, might be totally different when in practice. So this also made it for a lot of side-effects, some were pretty interesting, while others could be hard to deal with.
  5. Learned a lot of new concepts - learned a lot on the concepts of how to approach simple AI that should react to its environment. Also on how to approach making “sensors” for the agents and also the state machine.
The bad
  1. Maybe not really a game.. - our initial thought was to make it so there would be a player that could impact on one of the agents and the way it would react to the world. However we didn’t get so far, either way the product is more of a demo of AI-agents.
  2. Certain bugs were really hard to encounter - as we made the AI with several layers, that also added some more level of complexity to the project. Making AI isn’t easy, and sometimes things just won’t interact like you think it will. And because of this complexity it was pretty hard to find the origin of some bugs and also on how they would be solved.

Things that I would do differently are

  1. Spend more time planning advanced modules - When dealing with modules that will be pretty advanced like AI, it can be pretty good to set up a plan and way to approach the issue. We did some planning this jam, but we probably could’ve spent some more on planning and “designing”/discussing certain parts before implementation.
  2. Eat better - could probably prepare some decent food and greens in preparation of the next jam, so eating better/healthier food would be no problem.
  3. Isolating modules better - for a lot of projects this could be very good to try and do. So one can isolate certain issues, and try to scope down on certain problems that need to be solved. This could make for better workflow, and also maybe make the complexity and things to think of when creating a solution a bit easier.

What was different from previous game jam

  1. Got core features in earlier - last jam the core features of the game we made got done pretty late. However in this particular jam we atleast made it so core features were implemented pretty early so we had stuff to work with and see some actual interactions.
  2. Bigger scope - had a bigger scope than last jam. Which resulted in learning and dealing with a lot of new concepts, but on the other end we didn’t get as far as we’d like with the project.

Learning reflection

Pretty happy with the learning outcome, both in the aspect of working more in the Unity environment, but also on how to tackle and approach AI. Working with AI and with state machines was definitely an experience that has teached me a lot. Also really interesting how all these side effects, and thoughts on how interaction would work, would sometimes not work in practice as we expected them to. For the world-generation part it was pretty quick to deal with, as we have done a lot of generation in our game-programming project. However I learned some more about Unity’s events, and how to deal with them. (e.g. don’t instantiate GameObjects in an OnDestroy() Unity event)