# AI & Toxin hazard

**URL:** https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806
**Category:** Gameplay
**Created:** [July 11, 2021, 5:56pm UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806 "2021-07-11T17:56:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Maxonovien](https://thrivedevforum-cdn.b-cdn.net/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@Maxonovien](https://forum.revolutionarygamesstudio.com/u/Maxonovien)
#### Post date: [July 11, 2021, 5:56pm UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806/1 "2021-07-11T17:56:18Z")

</div>

Here’s a quick thought about AI running into toxins. It should of course, as a rule of thumb, avoid them (the how is another question, at the moment, they would need to get access to scene entities, and avoid if too close I guess).

However, I think that running into them is not necessarily stupid : in fact, when I have a lot of HP, I sometimes don’t care enough about toxins to divert my cell from gathering compounds.

A possibility could be to have a random chance to avoid it, with a formula like:  
`divertChance = 1 - HPFactor * BOLDNESS`  
`HPFactor = (currentHP - toxinDamageHP) / maxHP`

Boldness (between 0 and 1) could be an evolutive value, or some hardcoded value for a generic AI behavior. This could also perhaps be related to already existing factors (agressivity/opportunism?).  
Note that in any case, this formula would make sure that no cell will hit a toxin if this would be lethal to it, and `BOLDNESS = 0` would make a cell avoid toxins whatever.

* * *

EDIT: Current proposal  
`divertChance = 1 - HPFactor * BehaviorFactor`  
`HPFactor = (currentHP - toxinDamageHP) / maxHP`  
`BehaviorFactor = %FOCUS*(1-%FEAR)`

---

<div class="post-metadata">

### Author: ![Nunz](https://thrivedevforum-cdn.b-cdn.net/user_avatar/forum.revolutionarygamesstudio.com/nunz/32/1505_2.png) [@Nunz](https://forum.revolutionarygamesstudio.com/u/Nunz)
#### Post date: [July 11, 2021, 6:05pm UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806/2 "2021-07-11T18:05:10Z")

</div>

Instead of Boldness you could probably use the Fear personality trait as I suppose they are similar, or a mix of other traits like Focus and Aggression. If you go to Species.cs you can see all the personality traits which are Aggression, Opportunism, Fear, Activity, and Focus.

---

<div class="post-metadata">

### Author: ![Maxonovien](https://thrivedevforum-cdn.b-cdn.net/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@Maxonovien](https://forum.revolutionarygamesstudio.com/u/Maxonovien)
#### Post date: [July 11, 2021, 6:27pm UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806/3 "2021-07-11T18:27:10Z")

</div>

I pretty much like the idea of a mix: it diversifies behaviors without adding complexity.

I feel like Focus could be very suited, because I was specifically mentioning this before. Fear seems also to be adapted to this, so I think we could go like this

`divertChance = 1 - HPFactor * BehaviorFactor`  
`HPFactor = (currentHP - toxinDamageHP) / maxHP`  
`BehaviorFactor = %FOCUS*(1-%FEAR)`

Note: renamed `BOLDNESS` into `BehaviorFactor`.

---

<div class="post-metadata">

### Author: ![Thim](https://thrivedevforum-cdn.b-cdn.net/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@Thim](https://forum.revolutionarygamesstudio.com/u/Thim)
#### Post date: [July 11, 2021, 10:50pm UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806/4 "2021-07-11T22:50:03Z")

</div>

Can anyone speak to the role of the environment toxins in the first place? The player should never be running into them by accident, they rarely kill anyway, and once we upgrade the AI they aren’t a trap to lure other cells into. It seems that other than the AI messing up all the toxin does in gameplay is force the player to turn a little bit sometimes.

---

<div class="post-metadata">

### Author: ![Buckly](https://thrivedevforum-cdn.b-cdn.net/user_avatar/forum.revolutionarygamesstudio.com/buckly/32/1259_2.png) [@Buckly](https://forum.revolutionarygamesstudio.com/u/Buckly)
#### Post date: [July 12, 2021, 3:38am UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806/5 "2021-07-12T03:38:11Z")

</div>

Once we get currents they might become a bit more interesting. But until then they don’t have any clear meaningful impact on gameplay

---

<div class="post-metadata">

### Author: ![hhyyrylainen](https://thrivedevforum-cdn.b-cdn.net/user_avatar/forum.revolutionarygamesstudio.com/hhyyrylainen/32/2243_2.png) [@hhyyrylainen](https://forum.revolutionarygamesstudio.com/u/hhyyrylainen)
#### Post date: [July 12, 2021, 10:17am UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806/6 "2021-07-12T10:17:39Z")

</div>

They at least make moving require a little bit of attention, as there’s something to avoid.

> [@Maxonovien](#):
>
> they would need to get access to scene entities, and avoid if too close I guess).

I _think_ the AI chunks list should already include the environmental toxins…

> <https://github.com/Revolutionary-Games/Thrive/blob/c3d1cc035861007f3414c49d3e0b330d1276a96f/src/microbe_stage/MicrobeAISystem.cs#L29>

---

<div class="post-metadata">

### Author: ![Maxonovien](https://thrivedevforum-cdn.b-cdn.net/letter_avatar_proxy/v4/letter/m/f4b2a3/32.png) [@Maxonovien](https://forum.revolutionarygamesstudio.com/u/Maxonovien)
#### Post date: [July 12, 2021, 10:45am UTC](https://forum.revolutionarygamesstudio.com/t/ai-toxin-hazard/806/7 "2021-07-12T10:45:28Z")

</div>

Yes, I realized this shortly afterwards, they actually already have access.

Still, the point is that this design in itself could be changed: compounds-releasing chunks could by found by gradient-ascending their released clouds. There isn’t such a thing for toxins. So, while it actually fits in the current design, it adds further dependency on it, so double-thinking it is not completely useless, in my opinion. But I indeed think this could be pretty easily implemented as of now.
