mihahauke / deep_rl_vizdoom

Deep reinforcement learning in ViZDoom (using Tensorflow)
18 stars 8 forks source link

How can I change the monsters' coming out loction from random to regular in defend the center scenario? #10

Closed ouyangzhuzhu closed 6 years ago

ouyangzhuzhu commented 6 years ago

Quesiont 1: i want the monsters coming out from the place where it was born at the first time, no random, like they coming out in opening script ,how can i do it ?

first , in fact , I don;t quite understand the rule for the monsters coming out now In the openning scipt: the two types monsters coming together along the sphere every other same angle(0.2 here is : 0.0 ,0.2 0.4 0.6 0.8) SpawnTarget(0,0.0); SpawnTarget(1,0.2); SpawnTarget(0,0.4); SpawnTarget(1,0.6); SpawnTarget(0,0.8); When the monsters are kiiled , there will come out a new monster I think , BUT I don't quite understand the rule.

Here below is the wad file context:

include "zcommon.acs"

global int 0:reward;

int newId = 10; int r = 735.0; str monsters[2] = {"MarineChainsawVzd", "Demon"};

function int SpawnTarget(int monster, int spawn_angle) { int spawnedId = newId++; int x = FixedMul(cos(spawn_angle),r); int y = FixedMul(sin(spawn_angle),r);

int look_angle = (spawn_angle +128)%256;
str m = monsters[monster];

if(Spawn(m, x, y, 0.0, spawnedId, look_angle)<1)
    return 0;

SetActorProperty(spawnedID, APROP_Health, 1);
spawn_angle = random(0.0, 1.0);
SetThingSpecial(spawnedId, ACS_ExecuteAlways, 3,0, monster,spawnedID, spawn_angle);
return 1;

}

script 1 OPEN { reward = 0; SpawnTarget(0,0.0); SpawnTarget(1,0.2); SpawnTarget(0,0.4); SpawnTarget(1,0.6); SpawnTarget(0,0.8);

}

script 2 ENTER { ClearInventory(); GiveInventory("Pistol", 1); SetWeapon("Pistol"); GiveInventory("ClipBox", 6); }

script 3 (int monster_class, int id) { Thing_Remove(id); reward = reward +1.0; delay(90); int spawn_angle = 1.0; while(SpawnTarget(monster_class, spawn_angle++)<1) { delay(1); } }

Quesiont 2: I tried modifing the wad file , after saving it , then i run the model with test command, but the scenario did not change. eg: I change this line : from str monsters[2] = {"MarineChainsawVzd", "Demon"}; to str monsters[2] = {"Demon", "Demon"};

but the monsters then still two types , not Demon only....How can I make my new wad file work then?...

ouyangzhuzhu commented 6 years ago

I can answer ther second question now! because after editing the acs script that is my .wad file, we need compile it with acc.....: Save the ACS script entry and compile it by right clicking on the entry -> Scripts -> Compile ACS. Without compiling it won't work., the original link is here: https://github.com/mwydmuch/ViZDoom/issues/319

Miffyli commented 6 years ago

The defend_the_center.wad can be bit confusing, but you can change it to deterministic by commenting out lines 51-56. However it won't automatically spawn enemies when you kill one with this change. You could make monster spawn always from same location with following change (not tested):

script 3 (int monster_class, int id, int spawn_angle)
{
    Thing_Remove(id);
    reward = reward +1.0;
    // shoter spawn time (from 60s to 10s)
    delay(10);
    while(SpawnTarget(monster_class, spawn_angle)<1)
    {
        delay(1);
    }
}

Every time monster is killed, script 3 will spawn that same monster in the original location with 10s delay. Original code selected random angle. You can change the spawn_angle to suit your needs.

ouyangzhuzhu commented 6 years ago

3ks friend Miffyli , your suggestion works again!! and by the way do u know how to control the rule the monsters running, that is I want the monsters come to my agent along the straight line from their born point to the center, when i put fewer monsters along the circle, we can see that monsters which spawn_angle is bigger prefer first go along the circle to the middle of the circle , then go straight forward to attack the agent . Is there any functions i can modify?...........i guess maybe deeper in the game engine,,,,,,,,

mihahauke commented 6 years ago

I doubt it but you could look for something in zdoom wiki.

ouyangzhuzhu commented 6 years ago

Here is the way to control the monsters patrol route: 1> first , add the pathnodes in the map with the Doom Builder(slade works not very well for me ,so I finally use Doom Builder), here is the tutorial: https://www.zdoom.org/zdkb/zdoom7.html and here the some short videos can help u be farmilliar with the Doom Builer in a short time: http://doombuilder.com/index.php?p=tutorials 2> in ACS script, u may need the Thing_SetGoal function , u could check more info in zdoom wiki eg: the below means the monster with spawnedID will go to the pathnode 6 Thing_SetGoal(spawnedID,6,0);
3> If u want monster go along the patrol route ignoring the palyers, u may use the Thing_Hate ,u could check more info in zdoom wiki eg: the below means the monster with spawnedID will hate the thing which ID is 100 and our player's ID is usually 0 or 1(or others u can set as u like), so the monster will never attack out player. Thing_Hate (spawnedId, 100, 6);

here is my modyfied wad file~~: defend_the_center-0702-03_player_high_z.zip