Project goals for this month

Hello there!

It’s been a while since I wrote something about Simulation Pills. But to reward your patience I’ve decided to give you peek into whatever I am planning for this month:

  1. Implementation of item system
  2. Automated need based crafting
  3. Non-telepathic communication between pills

So there you have it. Hopefully I will be able to obtain goals listed above, and back up project with some more commits as the time passes. Also I wold like to write more „quality” posts, like that one.

That’s all for now!

Project goals for this month

Moving on

So that was pretty lazy weekend for me. I’ve decided to have some kind of reboot. I was watching „Under the dome” and „Vinyl” (amazing shows, totally recommended), reading newest Jaroslaw Grzedowicz book called „HEL3” (with cover reminding me the last DOOM) and hanging out with friends. I desperatly needed that.

So having that out of boat, here is update on the project:

It is not much – if pill does not know the location of need fullfiller it starts moving in random directon, until fullfiller is found. It looks kinda rad to be totally honest. Just like nomads, vagabonds (call them what you will \m/) searching for new place to live.

Still it would be fun, if they searched area in organised way with friends. I will propably focus on that in the next update (or on something completly different), so stay tuned!

Moving on

The solution

Recently I had very sad post, about certain things in my project not working too well. Today I found and implemented solution to that issues.

As I said before, I was thinking about holding default need values in XML file. That’s exactly what I did. There is an XML file with defaults in project, so you can check it out (and set your own values if you like).

Few words about the implementation. It is not rocket science, but some of you might find it interesting.

So that’s how XML looks like:

<?xml version="1.0" encoding="UTF-8"?>

I think it speaks for itself. It basically holds list of objects, where each one of them has need_type and value property. Before I’ve made parsing code I needed a data structure.I used, these are classes generated from it (after some changes in datatypes):

    [XmlRoot(ElementName = "need")]
    public class Need
        [XmlElement(ElementName = "need_type")]
        public NeedType NeedType { get; set; }
        [XmlElement(ElementName = "value")]
        public double Value { get; set; }

    [XmlRoot(ElementName = "needs")]
    public class Needs
        [XmlElement(ElementName = "need")]
        public List<Need> Need { get; set; }

I could propably do it myself, but saddly I am lazy person. Anyway, this solution works just fine, so it stays that way for now.

And finally – InitializeNeeds method

 public static void InitializeNeeds(PillAi pillAI)
            var path = "Assets\\Resources\\Needs.xml";
            var reader = new XmlTextReader(path);
            var serializer = new XmlSerializer(typeof(Needs));
            var defaults = (Needs)serializer.Deserialize(reader);
            foreach (var need in defaults.Need)
                pillAI.Pill.Needs[need.NeedType] = need.Value;

This solution still needs some work, but it does what it should. Default need values are no longer hardcoded.

But still, it is far from the solution I imagined. Yes, you can edit the XML but only before you build the game. After that, all asset files are packed into*.asset files. I want them to be accesible in builded version, so that is unacceptable. In the next post I will find the way of doing that.

But for now  – happy saturday! It’s the best day of the week, IMO 🙂

PS: I’ve updated „About me” page and it is in english now.

The solution

The struggle

Today something about  why this happened:


Maybe something about operation execution order in Unity too.

First of all, let’s look at piece of code

public static void InitializeNeeds(PillAi pill)
    var gc = GameObject.FindObjectOfType<GameController>();
    if (pill.GetNeedsDictionary() == null)
        pill.SetNeedsDictionary(new Dictionary<NeedType, double>());
    foreach (var key in gc.DefaultNeedVaules.Keys)
        pill.AppendNewNeed(new KeyValuePair<NeedType, double>(key, gc.DefaultNeedVaules[key]));

What you can see is static method that defines needs for every object on scene. It should do the job. But what I get after runing the game is…


Not the greatest result, isn’t it? But thankfully, Visual Studio has some cool debugging support for Unity, so let’s find out what went wrong.

And because it will be important later, this is GameController’s Start method

        private void Start()
            DefaultNeedVaules = SetDefaultNeedValues();
            Pills = FindObjectsOfType<PillAi>().ToList();

Again – DefaultNeedValues should be initialized first in order for InitializeNeeds method to work. What actually happens is InitializeNeeds being executed first. That means, my approach being wrong.

But that is actually okay. Default need values were one of ugliest examples of hardcoding I have made, and believe me –  I have made some.

I am thinking of keeping them in some kind of XML. So my next post will touch the subject of XML parsing in Unity.

The struggle

A pill that speaks

In world that I am creating every pill needs to fill its needs. As you may remeber from previous post, there are two basic needs implemented right now – food and water.

These needs will be possible to refill at „Need refill stations” as I call them now. I am not 100% sure how the refilling process will look at the end, but that is not today’s post subject. Today I will tell word or two about implementing communication between pills.

So firstly – why?

Well, communication is one of basic skills of intelligent lifeforms.

Secondly – how it works?

To be totally honest, o took the cheap and easy way of giving them telepathy. Every agent stores two lists of objects. First one is list of „Friends” – these are object that pill already met. Second one is list of known need fulfillers –  objects that pill will go towards when coresponding need fullfillment value is bellow the refill trigger value.

Now whenever two pills met, two big things are happening.

  1. Pills are chcecking their friends list, to check if the other pill is there. If not, pill is added to list and becomes friend.
  2. What follows friendship status check is information exchange. Both pills are exchanging informations about known need fullfillers, and update them if there is need to do so.

Information exhange occurs also when one of pills meets new need fulfiller.

That is basically it. It may not seem as much, but it looks like good starting point.

I have to admit, the project is a bit of clusterfuck right now. Coding without plan is can be at times a crazy fun, but this time I want my project to serve some purpose (even if that purpose is weird and uncommon). So I have a question to all reading – what kind of planning method do you use in your personnal projects? And how do you set goals in these projects? Are these goals clear or fuzzy?

Oh, all code is already on GitHub.

PS. The question stated at the end of post was also tweeted. If you are into tweeting, feel free to respond me there!


A pill that speaks

I’ve just drawn some ugly looking UML diagram.

Well, that was one hell of a clickbait. But let’s get into details, shall we?


I’ve decided, that this time, since goal of the project is to serve people of the internet who want to build their own world of wonders inside of a computer, I need to document whatever I am doing with it.

And yes, I think that means UML too. But since target of this project are developers I need to provide some kind of instruction. It will be in some kind of GitHub wiki I guess.

This week, while developing some code for this project I tested two UML tools.

One of them was StarUML. You can see output of my work bellow.


It is not impressive (never meant to be!). All I really wanted was simple class diagram, to not get lost, and well… It delivers, sort of.  But it requires time and skill, and I am not software analysis specialist.

So I needed something simpler. Luckily though, Visual Studio has cure for my needs.


It can be generated, and updates automatically as I edit the code. So it’s good for what I need right now.

How to make your own? Simply, really:


When it comes to implementation… Well there was some progress, indeed.

There is some basic intelligence implemented already. I’ve made up the following scene:


We have some kind of 3D box, our Pill and lots of grass. Our AI agent has hardcoded two basic needs – food and water. When they decrease bellow some level, he seeks for fulfiller of that need and goes there. That’s kinda it.

I am not going to get into details of the implementation, because you can check them out on my repository.

As the final note – question. How do you come to topic of documenting your code? Do you use UML, or just make notes?

I’ve just drawn some ugly looking UML diagram.

Super Spooky Santa Shooter 2D – czyli jedna z moich pierwszysch gier

Pochwalę się dziś czymś. W tegoroczne święta Bożego Narodzenia zbudowałem w Unity małą, zabawną (chyba) gierkę o Mikołaju strzelającym do prezentów.

Okej, to było trochę dziwne… Lepiej po prostu wam ją pokażę.

Graj w przeglądarce

Jest też dostępna wersja Windows i… Android!

Myślałem nad wrzuceniem na androidowy sklep, ale na razie muzyka w tej grze nie jest moją własnością.

No cóż… To tyle 🙂

PS. Nie martwcie się o Base.RTS. Projekt powstaje… W bólach 🙂

Super Spooky Santa Shooter 2D – czyli jedna z moich pierwszysch gier