eDonnes124 / Town-Of-Us-R

An Among Us mod containing a bunch of roles
GNU General Public License v3.0
335 stars 135 forks source link

Implement Weighted Role Selection System #253

Open GameTechGuides opened 1 month ago

GameTechGuides commented 1 month ago

Related to #252

Implements a weighted role selection system to adjust player roles based on previous game outcomes, enhancing the game experience by reducing role repetition for players across sessions.


if there any thing to do modify or something else feel free to ask me

@Enduriel

AlchlcDvl commented 1 month ago

i'm pretty sure when a player leaves the game, the player ids below the leaver's get pushed up, so the method of using a dict employing the use of player ids might not really work/be very ineffective. maybe add a case for disconnections?

also if a session goes on for long enough you might end up with really large lists which might end up affecting performance so you might have to occasionally clear them, maybe clear a list if it exceeds 10 roles?

Enduriel commented 1 month ago

@AlchlcDvl I like your thoughts on disconnections, agreed that some kind of handling there would be neat, could perform some kind of handshake where the host gives each client a uuid which they can hand back when reconnecting.

As for really large lists, I think this is a bit of an overoptimization, as this is pretty trivial in both computational complexity and memory size, but maybe a limit of 100 in case something goes terribly wrong is reasonable, even then it's in the range of 1000-2000 iterations max which is still unnoticeable on anything that can run among us in the first place.

AlchlcDvl commented 1 month ago

yeah fair, i was just giving 10 as like a random number, even i felt like it was way too less lmao

GameTechGuides commented 1 month ago

@Enduriel i have added The Role History List does nit exceed 100 entries and the method CalculateWeightedRoleProbabilities in AmongUsExtensions.cs for future calculation of role probabilities based on session history

for more see the new code

i still dont know if i should call The CalculateWeightedRoleProbabilities

Enduriel commented 1 month ago

Some issues, you're not using MaxRoleHistoryListSize, and according to spec RemoveRange will throw an exception if a negative number is passed in count.

GameTechGuides commented 1 month ago

Some issues, you're not using MaxRoleHistoryListSize, and according to spec RemoveRange will throw an exception if a negative number is passed in count.

oh yeah i didn't pay attention to that i will fix it soon i'm busy now

GameTechGuides commented 1 month ago

@Enduriel i have fixed the issue