• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Fixed Reluctance of AI captains to use all their perk points

But if there's always a random chance that a perk point isn't spent, then there is a certainty that those points get accumulated eventually, no?

Have you tried levelling up characters to, say, level 50 to see how many spare points they're left with?

Anyway, it could be that I'm misunderstanding something here.
But if I am, then @Tingyun wouldn't have reported so many unused perk points, would he? :confused:
 
But if there's always a random chance that a perk point isn't spent, then there is a certainty that those points get accumulated eventually, no?

Have you tried levelling up characters to, say, level 50 to see how many spare points they're left with?

Anyway, it could be that I'm misunderstanding something here.
But if I am, then @Tingyun wouldn't have reported so many unused perk points, would he? :confused:
most of my testcases in the past where only with lower level characters.
If you level a character manually to level 50 it will have less unused perk points.
If a character is generated without using post-init it will only call the perk selection function a couple of times to save on loading time. For lower level characters this seems to work but for some higher level character maybe this function should be called more often like tingyun sugested some of the paramters must be changed.

For now I think the system works right, it's just a matter of finetuning some of the parameters. there are a lot of paramters which determine which perk a AI will select.
 
So @Tingyun looking at this again:
Code:
        int chance = 100;
        if(hval <2) chance -= 40; //If the score is only 1 we have a 50% chance of taking this perk. There might be something better or we should wait till something with more points comes along
        if(sti(chref.rank) < 10) chance -= 25; //If we are below level 10 we should have a large chance of skipping a perk because there is a large chance something better is out there.
        if(sti(chref.rank) < 20) chance -= 15; //If we are below level 20 we should have a chance of skipping a perk because there is a large chance something better is out there.
        if(type != GetAttributeName(GetAttributeN(PerkTypes, sti(chref.PerkTypes.highest)))) chance -= 35; //If this isn't the best PerkType we should have less chance of picking one.
        if(rand(100)<chance)

I see it's possible to get over 100% chance to actually skip to select the perk.
So I sugest to change it to these values, could you check if you agree?

Code:
        int chance = 100;
        if(hval <2) chance -= 30; //If the score is only 1 we have a 30% chance of taking this perk. There might be something better or we should wait till something with more points comes along
        if(sti(chref.rank) < 10) chance -= 25; //If we are below level 10 we should have a large chance of skipping a perk because there is a large chance something better is out there.
        if(sti(chref.rank) > 20) chance += 25; //If we are above level 20 we should care less about saving up for perks and just take these damn perks already.
        if(sti(chref.rank) > 35) chance += 40; //If we are above level 35 we should just take the perk. By now everything what is left should be good anyways.
        if(type != GetAttributeName(GetAttributeN(PerkTypes, sti(chref.PerkTypes.highest)))) chance -= 35; //If this isn't the best PerkType we should have less chance of picking one.
        if(rand(100)<chance)

This should make sure a lower level character will save up on some perks. As soon as you pass level 10 you should start spending your perk points a bit more already. Once you got past level 20 you should take most but somtimes save up a little bit.
After level 35 You should always have a 100% chance of actually taking the perk
 
@Levis makes sense on the noncontribuute system removing some of the need. I'll add your revised skipping code, and finetune the reduced catagory system I used last night. I'll spend a couple of hours (either over lunch, or tonight) on testing. I've got an expanded tavern hire file that lets me test captains and crews as well as officers, I'll keep testing until it gets the variety you have in mind.

If it works well, we won't need to expand the number of times it goes through looking for perks--I tested generating level 20-50 guys on my previous rougher system, and they basically all finished they perk selection in advance (they were a couple of "no more perk points" results repeated at the end for them). With the reduced catagories they basically always roll up something they can pick.

@Pieter Boelen anyone over level 20 skips post init, so if I understand correctly they won't ever experience the below level 20 chance of skipping. I think, we'll see. I'll make sure the high level captains get everything spent, the reduced catagories should make sure of that.

On performance, I think we will end up getting a boost from less catagories. I entered and exited dungeons repeatedly, and loading times were faster. :)
 
Last edited:
@Tingyun captains for example have the skippostinit attribute set to them as do boarding crew. this is to make sure they are always fully generated because I need data from them.
If you get the notice for no more perkpoints left its no problem. thats a very early escape and almost wont add any processing time.

Feel free to experiment with the perk categories, i still had it planned to check but you can do to, seems you understand how the system works. I hope this is because I commented my code well :p.

Please do mind in future situations I might use these catagories for other things too (like grouping perks in the interface to these catagories).
 
@Levis yes your comments made it all very understandabke! It was like reading an instruction manual. :)

I won't delete anything, I've learned now to just comment out, so the old catagories will be around if needed.

Yes I think all the skipping perk selection was why processing times went down, everyone completed their seleciton ahead of schedule. And it provides a nice buffer to make sure they had enough tries.
 
@Levis

Here is a first attempt. I divided into three catagories,
1) personal combat
2) ship related
3) trade/commerce/smuggling/sneaky etc

Most roles have one set of things in number 2, so it probably works pretty much as well as having 8 categories now that we have the noncontribute mechanic.

All 7 ship related skills add 1 point each to ship related.

Fencing has a 5 rating for personal combat, nothing else factors in

This seems extreme, but it actually seems to get close to the result we want. The idea is that most characters have a mix of the other skills, so they don't need much of a multiplier there, they are getting it across multiple sources. And we don't need accuracy or grappling factored into personal combat, because the same officers having those skills also have at least some fencing, and it would just work to countermand the inclusion of those in ship related.

We might need a controntibute chance for most officers, but much lower (since they have more skills on the list to roll the noncontribute for), something like OfficerTypes.(type).noncontribchance = 2;

Captains spend all their perk points when they get high level, low level officers seem to pick well.

Performance wise, my impression is this is lightning FAST. Dungeons, towns, everything is loading much faster, even with postinit set to 0. With postinit left on, I no longer notice any drag in the first few moments.

The debug logs seem to indicate the reason why--much shorter, crated characters are finishing their perk selection quickly with little need for repeats in comparison.

There is one problem--they pick perks so well that even with the things Levis has set up to make them skip perks at low levels, they don't seem to do so enough, and still end up spending all their points. This is good for random characters, fighters, etc, but if you want hirable officers to save up a point or two, there will probably need to be something more to cause it.

So, turning if over to you Levis for further improvements or complete scrapping or whatever, or to see if it gives you the kind of officers you like already. I think with your improvements this will basic plan will work pretty well, especially performance wise. :) Btw, I am not sure changes in these files make it into current saves, it seemed like I had to start a new game to get the effects of changes in the catagories, not sure though.

What we might want is some check to randomly point to it to the lower valued list or lower valued perk, to introduce more variety so they pick "wrong" slightly more often. Not sure how to write that. :)

EDIT: pulling out file and reuploading with the forgotten perks_init below
 
Last edited:
I will take it from here then. Thanks.
 
@Levis Please forgive any stupid errors I made--and I understand if you end up having to scrap my whole attempt and start over. And really, thanks for everything you are doing to improve the game. :)
 
@Tingyun did you forget to include the perks_init file? Doesn't matter now though because I will go over it myself again.
 
@Levis I did indeed forgot to include it in the archive! Well, wouldn't work at all without that file, noone would get their needed perks into the new catagories. :p

Reuploading here, now with the missing file, sorry about that.
 

Attachments

  • Perk selection.rar
    22.6 KB · Views: 74
@Levis Just got informed the project is finally starting up at work tomorrow, so have to say goodbye for now. :(

I don't know if this would be useful, but it is a tavern dialogue thing I made to quickly generate the 4 types of captains and 4 types of normal enemies (Sailors, pirates, randchar, guards), by replacing each of the normal officers, and adding levels to the captains but keeping the crewmembers lower level. I found it useful in testing how they spend perk points, not sure if you would, but just in case it might be useful here it is.

Thanks for all your advice on coding and the fun chance to learn over the past weeks, and I look forward to seeing you again once the project wraps up! :)
 

Attachments

  • tavern.c
    5.3 KB · Views: 87
Last edited:
I've went over it myself also and with the sugestions of @Tingyun I came up with this version:
Mod Release - Levis' Stuff [Sept 27] | PiratesAhoy!

Also implemented your idea for the tavern but a bit less crude. So if you set DEBUG_TAVERNTYPES to 1 in Leveling.c you will get another option in the tavern where you can select all avaible officertypes and determin the offset they should be generated on.
 
Back
Top