It’s pretty straightforward to simply write a program that has hard coded algorithm to every individual interaction such that it looks mostly like RAR to an outside observer.
But actually translating the rules of RAR into code is difficult. I kept running into situations where I have to make an exception somewhere.
For example in order to make sure it’s giving non-arbitrary outcomes I coded it to resolve each role in a random order.
With every role besides the bus driver I was able to do this just fine. And the bus driver was able to work under standard situations. However there were always situations where it would break down with either more than 2 bus drivers or bus drivers combined with roleblockers.
If I were to code this again a lot of it would probably still be very useful. For example I was able to implement a resolution que that can consistently handle infinite regress situations (ex: Roleblocker targets a jailkeeper targets roleblocker and the roleblocker is attacked. The roleblocker is killed btw).
Basically the way my code worked is you input each players targets (works for an arbitrary number of players including citizens) and it stores a list of each player, their role, who each player is targeting and a list of who is targeting each player (having 2 lists for this is useful since it lets you work backwards from the recipient or forwards from the instigator of an action) from there the lists are randomized for testing purposes (to ensure no interactions are dependent on the list order. This is unnecessary for actually implementing it)
Each player is selected an an algorithm determines what happens to them based on what roles are targeting them, what roles they are targeting and what roles are targeting the player they are targeting. It then also resolves the roles that effect them in a que which stops if it either runs out of players or if it encounters the same player twice (in which case it ignores them the 2nd time). The function for tracking this is recursive but the que prevents an overflow.
It then checks the status of each player base off of what happened to them in the previous part of the code and what they did in order to determine exactly what their final night results should be, which is then displayed in a list
While I haven’t tested it, this should be able to process both Hunters mark and Party. Although a party would be bypassed by a roleblocker directly targeting them unless we make them immune.
Occupy I know for a fact can work.
Tornado and Debauch were where I had problems getting this to work. I tried a separate redirection function with some failsafes and a separate resolution step to double check where everyone should end up going, but there were always specific interactions where this broke down.
Despite this the program one of the ones I am the most proud of. Maybe I should remake it and try again to get it working and with more features?