youvsvirus / youvsvirus-unity

Unity version of the you vs virus game.
GNU General Public License v3.0
1 stars 1 forks source link

Improved Social Distancing and NPC behaviour #57

Open ghost opened 4 years ago

ghost commented 4 years ago

Overview

Right now, social distancing is almost binary: Either, every contact leads to infection, or no contact does.

Instead, when social distancing is high, NPCs should actively work to keep their distance, but should still be allowed to touch (e.g. in overcrowded areas). This can be implemented by a kind of 'comfort zone'. If another human comes into an NPC's comfort zone, it should attempt to move away from it.

Also, NPC's infection radius should be smaller when social distancing is higher, simulating less contact with people close by.

NPC Behaviour

NPCBehaviour

Parameters

In the DefaultNPC prefab, a few parameters can be changed to influence these behaviours:

NPC Script

Comfort Zone Script:

Checklist

maccxs commented 4 years ago

I would like the "moving away from each other" stuff. I will keep working on improving the SEIR model, where not every contact leads to an infection... you can already have a first look at it in the resepective branch. If you watch the SEIR Game-Object during play, you see the SEIR mdoel predictions compared to the visualization by the SMILEYS (which is not one to one due to their randomness).

holke commented 4 years ago

When social distancing is high, some NPCs should stop moving at all, because they „stay at home“. This feels much more like the real world social distancing.

maccxs commented 4 years ago

Maybe then put a little house around the smiley where he is safe.

maccxs commented 4 years ago

Like this one https://pixabay.com/vectors/building-house-home-real-estate-295207/, no door, instead smiley inside

ghost commented 4 years ago

I like that idea :) NPC's that stay at home can't be infected. I think NPCs should alternate between staying at home and moving outside during the game, but the higher social distancing is, the less they should leave the house. Also, maybe sick NPC's (red smiley) should stay at home most of the time.

How about we fix the starting position of an NPC as their home, and have them return there regulary?

ghost commented 4 years ago

I'm implementing the behaviour graph I added above. Any comments / opinions? For now, I'll make it so that an NPC just 'builds their home' wherever they are at the moment.

ghost commented 4 years ago

Since NPC behavior becomes more and more complicated with this issue and #61 , I recommend we use the GitHub Wiki to keep track of all the components, their interactions and the way they control the NPC's behaviour.

maccxs commented 4 years ago

I like the behaviour graph. I would say that the NPCs do not run away if someone is in their comfort zone but rather walk around / make space. / stay to the side as we would do in the real world! The NPCs could first simply build a house where they are, I agree. GitHUb Wiki, yes!

maccxs commented 4 years ago

What I would like for my infection model: Knoledge about how long one human was "near" another one. Which I would like to have influence on the spread. So if you see a way to integrate this easily, I would be happy.

maccxs commented 4 years ago

The red smileys have symptoms but the should not necessarily stay home, rather stay home more. Beccause not everyone with symptom is really very sick. Only a fraction of them, so make this variable.

ghost commented 4 years ago

@maccxs Check out the playground scene I made for testing the comfort zone. (Branch frederik/advancedSocialDistancing). Enter play mode and move the NPCs around in the scene view. Then you can see green lines between NPCs who are in each other's comfort zone, and red lines which show the calculated escape directions.

Right now, I'm finding the direction that leads as far away from all NPCs in the zone. Since in RandomMovement mode, NPCs do not have a target they want to get to, I think just trying to get away is fine. If there is a target (like a supermarket, home, ...), we can add the direction to the target into the calculation, making the NPC move around others.

maccxs commented 4 years ago

That sounds fine. I will have a look at that branch this evening or tomorrow.

ghost commented 4 years ago

What I would like for my infection model: Knoledge about how long one human was "near" another one. Which I would like to have influence on the spread. So if you see a way to integrate this easily, I would be happy.

That's easy. I'll give you an event in the comfort zone script you can subscribe to from your infection model like this:

// Assuming npc is an NPC
ComfortZone zone = npc.GetComponentInChildren<ComfortZone>();
zone.HumanEntered += HumanEnteredHandler;
zone.HumanLeft += HumanLeftHandler;

with

class ComfortZoneChangeArgs : EventArgs {
    public float timestamp;
    public NPC comfortZoneOwner;
    public HumanBase other;
}

You have to define

private void HumanEnteredHandler(object sender, ComfortZoneChangeArgs args) { ... }
private void HumanLeftHandler(object sender, ComfortZoneChangeArgs args) { ... }

These methods will then be called whenever another Human enters or leaves someone's comfort zone. From the args structure you can then build your statistics ;)

ghost commented 4 years ago

You are invited to play around with the parameters which control the behaviour and find the settings which feel most natural. I listed them all in the issue description.

maccxs commented 4 years ago

Ok, I will. Thanks!

maccxs commented 4 years ago

I tried it out and I do not really have any big change requests. Maybe just some small comments:

ghost commented 4 years ago

By the way, I guess you have noticed that I've been inactive the past week. The summer semester has started and demands its toll. I hope I can catch up and get something done again next weekend :)

maccxs commented 4 years ago

Hi @FredyHennig: Good to hear from you. Your studies, of course, are much more important than contributing here. That is perfectly fine. We were just a little worried since we did not hear from you. We decided to tackle the next relase with 3 levels that are described in the issues and one already existing party level. For these, we are not dependent on the new behaviour of the NPCs yet (which is a bonus, of course). I think, it is good to take baby steps here and not want to much at once. So, just work on it when you have time :-)