Page 1 of 2

New Difficulty mode

Posted: 18 Apr 2013, 15:46
by jh0242
Hello everyone,

I am currently looking into developing a dynamic difficulty adjustment strategy in Warzone 2100. That is, a difficulty that adjusts to a players skill level while the player is playing the game and saving that state for future games. Rather than wading through the code aimlessly, could anyone give me a good starting point, such as where the Droids are initiallized or scripts that hold damage, health, etc. Any and all input is greatly appreciated and I apologize if I am in the wrong forum section.

jh0242

Re: New Difficulty mode

Posted: 18 Apr 2013, 16:42
by Per
For campaign?

I'd guess the non-ini droid loading function used by campaign in src/game.cpp would be the right place for that...

Re: New Difficulty mode

Posted: 18 Apr 2013, 17:07
by jh0242
I would like the difficulty to apply to campaign and bots in skirmishes. Basically I will take data such as user overall damage and ai overall damage, number of units, health, etc. and use an algorithm to lower or raise the stats of the ai to meet the player's skill level. Basically I need to know where the enemy units are created at (which file) when the player creates them in game and how the unit's stats (damage, health, etc.) are assigned. Are constant variables used? Where are those variables? Where are those variables used? Any and all information is greatly appreciated.

Re: New Difficulty mode

Posted: 18 Apr 2013, 18:20
by Per
Starting reading src/droid.cpp

I'm not sure this is a good idea, though... People like knowing what they are playing against. "I beat the AI on hard", sounds a lot better than, "I beat the AI again today, and it is probably a bit harder than last time but I have no idea what has changed."

Re: New Difficulty mode

Posted: 18 Apr 2013, 19:10
by jh0242
I will add statistics demonstrating comparisons, maybe by percent or z-score, on how much more difficult or less difficult the AI, basically providing a way to gauge your own skill level.

Re: New Difficulty mode

Posted: 18 Apr 2013, 19:19
by NoQ
Well, if only a computer had a way to figure out how well does a human play, i would have had much easier time writing AIs XD

Re: New Difficulty mode

Posted: 18 Apr 2013, 20:01
by aubergine
Allowing AIs to persist data across multiple games would be super-useful for adaptation. Maybe something for 3.2 branch?

Re: New Difficulty mode

Posted: 18 Apr 2013, 20:29
by NoQ
Or even for manual teaching (like understanding a chat message of "hey, please try to remember to build defenses around this spot next time").
Not sure how exactly i really want it to be implemented.

Re: New Difficulty mode

Posted: 18 Apr 2013, 23:56
by Per
A simple key:value table stored persistently for each script-name? (Like we have a log file for each script-name now.)

Re: New Difficulty mode

Posted: 19 Apr 2013, 02:38
by aubergine
Possibly, but IMHO a JSON formatted file might be nicer (particularly for easy viewing / debugging).

Re: New Difficulty mode

Posted: 22 Apr 2013, 20:06
by jh0242
Which files contain the code for creating new cyborgs or tanks when the user clicks to create them?

Re: New Difficulty mode

Posted: 23 Apr 2013, 03:40
by aubergine
@jh0242 - the .txt or .ini files (depending on wz version), often under the stats folder. Eg. body.txt / body.ini defines the tank and vtol bodies. There's some info under the Development tab (top of this page) about the stats files.

Re: New Difficulty mode

Posted: 29 Apr 2013, 03:53
by jh0242
I meant in the src folder, which .cpp or .h file/s. But that information is helpful as well, thank you aubergine.

Re: New Difficulty mode

Posted: 29 Apr 2013, 08:20
by Per
jh0242 wrote:Rather than wading through the code aimlessly
If you are going to do this, you are going to have to wade through a lot of code. You start in droid.cpp and statsdef.h and trace everything from there. While I'd be happy to help with concrete questions, you will need to learn your way through the code base yourself. See it as a learning experience. Do not post multiple duplicate topics asking us to do all that work for you.

Re: New Difficulty mode

Posted: 29 Apr 2013, 18:32
by jh0242
I know that I am going to have to wade through the code and I am happy to do so. I have been reading through it and I feel as though I am starting to understand the structure. However, I am not sure where the units controlled by each player, including AI, are held. It seems to me that the loop.cpp file is where the game is being controlled, but where are the arrays (or other storage structure) of droids being held and acted on throughout the gameplay? If I can get that little bit of information, I feel I will have a great starting point. I am sorry for any confusion or misuse of posts and thank you for any help you can provide.