# Thinking about AI

**URL:** <https://forum.revolutionarygamesstudio.com/t/thinking-about-ai/60>\
**Category:** Theory\
**Created:** [June 14, 2015, 4:22pm UTC](https://forum.revolutionarygamesstudio.com/t/thinking-about-ai/60 "2015-06-14T16:22:40Z")\
**Posts on this page:** 1\
**Showing post:** 33

<div class="post-metadata">

**Author:** ![TheCreator](https://thrivedevforum-cdn.b-cdn.net/user_avatar/forum.revolutionarygamesstudio.com/thecreator/32/64_2.png) [@TheCreator](https://forum.revolutionarygamesstudio.com/u/TheCreator)\
**Post date:** [July 1, 2015, 3:08pm UTC](https://forum.revolutionarygamesstudio.com/t/thinking-about-ai/60/33 "2015-07-01T15:08:14Z")

</div>

> [@tjwhale](#):
>
> Here’s another video with 10 microbes all running the same ai. I made some changes (you can see I sped it up).

Personally, I liked the speed of the old one a lot better. It was more relaxed and easy to see what is going on, but I guess this is more of a personal preference.

Now, I am pretty sure that this is what you planned for this prototype originally (else why would you have an events memory bank for each creature), but I will still ask it just to be on the safe side. We don’t actually plan to have strength values determine fights in the real game, right? The strength memory is an excellent idea to rank different species and to know who to attack, but I always thought that in the real game fights would be determined by combat. Unless of course that would be computationally expensive and having a strength value is the only way.

Then again, where would the population dynamics play into this? If we only use your described system for organisms on the players screen (and the 8 tiles around it for seamless transitions) how will we be able to fill up the memories of the cells quickly and efficiently enough? I think we need to find a way to use the population dynamics equations to affect the strength memory of creatures. That is, unless I am completely misunderstanding how the system is planned to work in the future; in that case I apologize for my pointless rambling and hope that someone can enlighten me.

> [@tjwhale](#):
>
> I tried wrapping the window round as you suggest (I’d probably call that periodic boundary conditions) however the path finding started doing weird things. As soon as a microbe crossed the boundary it would decide it wanted to go back and would sort of flicker. I could rewrite the path finding to find the shortest route including paths that go over the boundary but didn’t want to bother. However I agree, the boundary is very artificial. One thing I might try next is to say if they reach the boundary they are despawned. That’s what happens in the game and so is the most realistic, new ones should probably be spawned on the boundary too.

Yeah, that makes sense; we probably shouldn’t waste times on something that isn’t going to make it into the game. It worked for me since that is how I set up my system originally, but your idea about despawning creatures is great. Although one thing I might add is that we should calculate 9 times the area of the viewing rectangle (basically a 3x3 square with only the middle square rendered). I suggest this because if you despawn a creatures as soon as it leaves the boundary, the things chasing it will stop seeing it and will turn around, which would also look artificial.

> [@tjwhale](#):
>
> Each microbe has a separate events memory bank for each other species. So I have a memory bank, with 50 slots now, for species A and a completely separate one for species B etc. So if there are 10 species I have 10 memory banks. (Well 9 really as you don’t need one for yourself).

Aye! That makes so much more sense. Here I was thinking that it had an only one events memory bank for _all_ creatures.

> [@tjwhale](#):
>
> Yeah good point, I’d like to start using partial values as well. (So the outcome can be 0.3 or something like that).

Partial values should work by comparing the state of the creature before the combat and after. I propose that we first assign a 10 value to every organelle and then add this up. For example, if we have a barebones plant cell with a cell wall, membrane, 2 chloroplasts, mitochondria, and a vacuole we would have 10+10+2\*10+10+10=60 points. After this we look at the cell after the fight. For each organelle we will have a specialized function that judges that organelles health e.g., a vacuoles function could be:

```
Amount of compound after combat / amount of compounds after

```

The other organelles functions’ would depend on how we implement toxins. We will then add up the results of this specialized functions (say we get 5 + 3 + (8+2) + 4 + 8 = 30) and divide it by the original number: 30/60=0.5. This is the number that would get inserted into the events memory. This would remove cases when A beats B 10 times and thus gets 1,1,1,1,1,1,1,1,1,1 with a 100% probability but is virtually dead after all the encounters and in reality should have a 0.1,0.2,0.05,0.1, etc…

> [@tjwhale](#):
>
> The thing is if you can move and you are really strong you want to hunt, you’re just wasting resources by not doing so. it just makes sense. If you are really strong and can’t move then you just never get scared but you don’t hunt.

Yeah, that makes sense. I didn’t realize that your system works in the case that I described.

Anyway, I will look at your code in the github directory, scower this topic and put all of the ideas into a code flow chart so it will be a breeze (hopefully) for @Moopli or @crovea to inplement this. Also, know that I think about it, our AI is looking a lot more than a behavioral tree than a finite state machine, not that it matter much.

Edit: didn’t realize that @Seregon has posted before me. I’ve read through it, but it’s too late where I am to reply. You bring up some good points (some of which are incidentally what I just wrote) and I’ll try to reply to them after I wake up.

---

_[View the full topic](https://forum.revolutionarygamesstudio.com/t/thinking-about-ai/60)._
