amacati / SoulsGym

Gymnasium extension for DarkSouls III, Elden Ring, and other Souls games
MIT License
115 stars 9 forks source link

HP UI Of Player And Boss Don't Decrease #48

Closed ListentoMe0112 closed 8 months ago

ListentoMe0112 commented 8 months ago

Thank you for provide such wonderful env. But I,ve got some glitches while using the package.

I'm not a native English speaker, so plaese pardon my poor English.

[Machine and Software] python 3.11.2 soulsgym1.1.0 Win11 DarkSouls steam with lateset version

[Question] I use Iudex Env, there are something wrong descript below:

  1. Althrough Observation of Boss's and Player's HP is decreasing, the UI doesn't change.
  2. The HP of Boss is below 400, but cann't enter Phase II

Is there something I can do to fix this? Look forward to your replay.

amacati commented 8 months ago

That's actually not a glitch, it's by design. Each environment step the player HP and boss HP are reset in the game. The gym accumulates the HP differences internally. That way the player never dies and we can reset everything by simply resetting the internal state. Dying would mean the game has to reload and the env has to run through its setup again. Avoiding that allows the environment to generate more samples per minute.

There is another reason for resetting the HP at every step. There are ways to avoid a player/boss death without HP reset. However, if the boss transitions into its second phase, there is no easy way to reset it back to phase 1. This also forces us to reload. Instead, there is a keyword argument to the gym that sets the boss phase. You can fight Iudex in phase 2 by running gymnasium.make("SoulsGymIudex-v0", phase=2). The big drawback is that it is hard to train an agent on both at the same time and that the phase transition is never seen by the agent. To fix that I would need to find a hack that resets the boss phase though, and at this point I haven't yet found anything that allows that.

So to summarize, 1.) is expected. The HP does decrease, but it resets the game HP value on each env.step() call and only keeps track of any HP losses internally. 2) follows the same reasoning. To train against phase 2, you can set the option on gymnasium.make.

You can also read about it here: https://soulsgym.readthedocs.io/en/latest/envs/index.html

ListentoMe0112 commented 8 months ago

Thanks for your reply, I'll read document more carefully next time. Can I do something to cancel reset? When traninning is done, I want to do a simple presentation. The video you push on the youtude seems not to reset the HP and UI is correct. How can I achieve this?

amacati commented 8 months ago

Yes, I wrote a demo environment for exactly this purpose. I just discovered the docs for some of the modules are broken, hopefully I can fix that next week. But you can find it here and here in the code.

Replacing gymnasium.make("SoulsGymIudex-v0") with gymnasium.make("SoulsGymIudexDemo-v0") should work.

ListentoMe0112 commented 8 months ago

Thanks for your reply!