The Baby Now Thinks It's Hungry
Tags: ruby
Published: 2019-11-04 23:46:39

I've been peeking back at the HumAIn project on and off the past week and in spite of my progress, the process of abstraction of cognition has been getting increasingly difficult and for the sake of quicker development, I've made some potentially grounding design decisions that may hamper future progress. I may even start fresh and rebuild my model balancing intuitive design with more flexible functionality, assuming I can draw up a model like that at all.

That aside, the baby is now able to have goals based on his priorities. They are currently exclusively geared towards survival and are actually relatively simple.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/v60l38dhe2lnylc6tkzl.png)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ooaqsvyif8v2rutqrhdd.png)

Being hungry will add hunger to the beginning of the problems array in short memory, notifying the baby that hunger is the most pressing issue at the moment. This hopefully will be a hash with an urgency rating, but that's a later development at the moment. The decider method goes to problems, observing the first item and checking the long memory's associations to find the action that would be appropriate for the problem and setting that as a goal.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/jjgk76vu8gnpu1qvbzcg.png)

What the baby is thinking here is that hunger is its most pressing problem. It goes into its library of associations to find hunger and its related actions, finds eat, and sets that as its goal. The next step is naturally to make it seek out and eat any food in the area. The major limiter here is that the baby's knowledge of a thing's food quality is binary. There's no need to discover and learn about it, but for now that is out of the scope of the current progression.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5yiq0oae2hfk1gqkbbhm.png)

I now call a reactive action method that will choose an action dynamically. This will be more useful in situations where the actions are less definite and more options are available. Hopefully. The method currently gathers the relevant things out of associations in the form of keys that can be plugged if needed, while also referring to the baby's goal. The method sifts through the local area for objects that relate to the goal with a select method and assign that to its own variable. With these bits of information, the baby runs the BabyActions helper class.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/vwgoos5xupn0lsg1nrkc.png)

Here I had to make a handler to read the action and call the right action method to represent the action. Because I need to construct the environment and all actions programmatically in this CLI style program, the action is sort of rigged to only require the baby to realize he's hungry and attempt to eat and it simply happens. This doesn't test the baby's ability to perform multiple actions in a row to accomplish something and all kinds of things could make this functionality more elegant. I plan to make a few more tests to make my goals more clear when I get fed up with the minor inconveniences and start clean. In the meantime, I've played with what I have to see the function in action.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/vwsei9b0x1gjtljwuv6p.png)

I also put the look at method after the time pass method so you can see what the baby sees before it acts.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/u2elnkuwf4hm9ovok8o3.png)

When the baby can't find anything to eat, it just says it can't find a solution. 

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/hlbmbpugu00tvdlvpelr.png)