AI Aggression Randomization

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
User avatar
Foocaux
Space Squid
Posts: 78
Joined: Sat Jul 26, 2014 7:14 am

Re: Am I the only one who never won a game?

#16 Post by Foocaux »

PlayerID() by itself doesn't seem to provide too much randomness either...

I'm now trying to combine empire name & galaxy seed to the Seed() call to see if rand0 gets simultaneously consistent & a bit more random! :shock:

Patch incoming if it does! :)
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Am I the only one who never won a game?

#17 Post by Geoff the Medio »

Foocaux wrote:PlayerID() by itself doesn't seem to provide too much randomness either...
What do you mean by "doesn't seem"?

User avatar
Foocaux
Space Squid
Posts: 78
Joined: Sat Jul 26, 2014 7:14 am

Re: Am I the only one who never won a game?

#18 Post by Foocaux »

In my system AI number 1 will always be at max aggression, regardless of galaxy seed, or actual empire name, etc, etc...
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0

User avatar
Foocaux
Space Squid
Posts: 78
Joined: Sat Jul 26, 2014 7:14 am

Re: Am I the only one who never won a game?

#19 Post by Foocaux »

Ok, I've managed to make some progress: I got AI aggressiveness to be random in windows, and dependant on both AI empire name & AI playerID. I've started playing around with it a bit, bu RL is calling, so here's my patch, warts & all...

EDIT: in my first version of this post I somehow sent a patch that confused the AI name with its empire name. Not anymore! I don't think there are any major warts left & I'm pretty happy with it as it is now. 'Course, there could be warnings from gcc and/or clang lurking in there... :P
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: AI Aggression Randomization

#20 Post by Geoff the Medio »

As noted above, using the player ID for random seeding is probably a bad idea as it prevent reproducibility of setup results if the mapping between player name and id and empire id changes between game starts.

Also, the use of the custom name hashing function is potentially problematic. I suggest using the boost hashing method posted above.

Also, comments explaining some of what's going on with the range tests would be useful... it's very unclear what some of the code changes are doing.

User avatar
Foocaux
Space Squid
Posts: 78
Joined: Sat Jul 26, 2014 7:14 am

Re: AI Aggression Randomization

#21 Post by Foocaux »

Is this what you had in mind?
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13603
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: AI Aggression Randomization

#22 Post by Geoff the Medio »

This doesn't make sense:

Code: Select all

boost::lexical_cast<unsigned int>(empName)
Empire names are not (generally) string representations of integers.

Re:

Code: Select all

// if it's in the top 25% then decrease aggression.
Why?

User avatar
Foocaux
Space Squid
Posts: 78
Joined: Sat Jul 26, 2014 7:14 am

Re: AI Aggression Randomization

#23 Post by Foocaux »

That cast (as a fallback in case hashing fails) was there to still provide some variety based on the Chars comprising the empire name.

I simply followed the original example for galaxy seeds: they seem to be mostly alphabetical, but that very cast is used as a fallback: given that you told me to do the same for empire names as what was done for galaxy seeds, I imagined you meant for me to do everything the same way. Apologies if I misunderstood.


The 25% of AI with lower aggression is already implemented in trunk, for osx & linux.

I've just followed what was there already, implemented by Dilvish, I believe.

The 8% of AI having even less aggression was totally my idea, though.
I did pluck that second number - and lower aggression level - out of thin air, it kind of 'felt right', somehow.
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0

User avatar
Foocaux
Space Squid
Posts: 78
Joined: Sat Jul 26, 2014 7:14 am

Re: AI Aggression Randomization

#24 Post by Foocaux »

Ok, last iteration on mySeed generation. Yesterday evening I misread FO's original code, so the fallback mySeed generator was pretty useless.

Now with a working fallback generator, that can also be commented out... tbh I'm not clear why there's a need to bracket boost::hash inside a try/catch...
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: AI Aggression Randomization

#25 Post by Dilvish »

hey guys, I'm back. The combo of galaxy seed and empire name sounds fine/good to me, enabling reproducibility without creating excessive predictability.

As for aggression distribution, I had originally started with a broader distribution, but after a fair bit of feedback we settled on the current distribution simply having 25% to be a level below max. I think that's been working out fairly well, and I think that at least for 0.4.4 we should not change that.

We could certainly have another discussion about it, and perhaps we should wind up adding a new table for it into universe_tables.txt so that it could be more readily user-customizable.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Foocaux
Space Squid
Posts: 78
Joined: Sat Jul 26, 2014 7:14 am

Re: AI Aggression Randomization

#26 Post by Foocaux »

Hello Dilvish, do pick what's good from my patch, discard the rest! :)

Cheers.
The small print: Any code contribution I make to FreeOrion is made under GPL v2.0, any graphic contribution is under CC-by-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: AI Aggression Randomization

#27 Post by Vezzra »

Yep, and please merge the fix into the release branch too ;)

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: AI Aggression Randomization

#28 Post by Dilvish »

Vezzra wrote:Yep, and please merge the fix into the release branch too ;)
Sounds fine, though it may be another day or two until I get to that. Yesterday morning and this morning I took my daughters freediving for abalone (we got 4, hurrah)-- first time for them, and it's been over a dozen years since I've gone, so I am rather a bit exhausted just now.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6102
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: AI Aggression Randomization

#29 Post by Vezzra »

Take your time, FO is a hobby we do for fun, no need to rush anything :D

Oh, btw, concerning merging commits between branches/trunk (because you mentioned it in one of the other threads): The method you described of course should work, but there is a simpler solution: svn merge is your friend!

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: AI Aggression Randomization

#30 Post by adrian_broher »

Vezzra wrote:Oh, btw, concerning merging commits between branches/trunk (because you mentioned it in one of the other threads): The method you described of course should work, but there is a simpler solution: svn merge is your friend!
NO! svn merge without proper parameters will merge everything. Read http://svnbook.red-bean.com/en/1.7/svn. ... rrypicking before merging.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Post Reply