Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Mafia Theory: Game Structure  (Read 5594 times)

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Mafia Theory: Game Structure
« on: March 10, 2016, 03:27:33 am »

So, new thread because:
- the Mafia Setup and Discussion thread is actually about setups and not the core mechanics;
- the Banter thread isn't really the place to have concise and focused discussion (:P);
- necroing old threads is anti-town behavior.

This thread is to discuss the structure of the mafia base game, i.e. what actually defines a mafia game, the object model, and later how to process game actions.
The practical purpose of all this is to (eventually) program a flexible mafia engine, along with possibly a role generator and potentially (in the long-term) even a mafia bot.

Inspired by this post by NQT and his role generator (which is text-based, as I understand).
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #1 on: March 10, 2016, 03:35:42 am »

First off, I whipped out Visio and came up with this scheme:

Spoiler: Diagram (click to show/hide)

It's a rough representation of a class relation diagram. For those unfamiliar, [] signifies a list/array of attributes. The arrows (here) show class membership, not inheritance.
Any potentially additions?
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

notquitethere

  • Bay Watcher
  • PIRATE
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #2 on: March 10, 2016, 07:38:38 am »

A lot of games also have an implicit alignment property which is different to the wincon: the town's objective might be to destroy all anti-town players, but 'anti-town' isn't a win-condition, it's an umbrella of win-conditions.

The core part of the ability is what it actually does, the 'effect'. It also has a usage number (one-shot, two-shot, endless).
« Last Edit: March 10, 2016, 07:45:03 am by notquitethere »
Logged

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #3 on: March 10, 2016, 10:00:46 am »

Though I agree that alignments can be a thing... hmm...
It sort-of boils down to what would be more flexible. Wincons can also be compound wincons, as in "win if: TOWN players are
Yes, I see your point - it's hard to not "label" roles as being part of a group.

From an implementation point of view, I think that compound wincons are fairly easily doable, just need to figure out the base types, such as:
- if <alignment> eliminated
- if <alignment> is last standing
- if <trigger*>
- if <action used>
...

Tiggers are a pretty integral part of Mafia, right? I mean, they are basically the base for wincons and auto abilities. They're also probably the hardest thing to remember to check in a role-heavy game. I'd guess, implementation-wise, they'd be akin to events.
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

notquitethere

  • Bay Watcher
  • PIRATE
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #4 on: March 11, 2016, 10:08:27 am »

Yes, in a role-heavy game it helps to encorporate the triggers into a list of things to check at each action resolution.

So I've been working on a balanced role generator partly inspired by your chart that modularises the use phase/ability/target type. Adding weights to the elements and adding flaws/buffs accordingly. Still very much a work in progress, but these are the sorts of roles it's been spitting out:

(Night)(Target/Self) You can protect. All protects against you fail.

(Night)(Target 1-2) You can block. Your abilities have a 50% chance of targeting yourself.

(Anytime)(Target) You can kill. You die if your vote is on a town player when they are lynched. You have 50% chance of giving your ability away to a random player after each lynch.
Logged

Shakerag

  • Bay Watcher
  • Just here for the schadenfreude.
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #5 on: March 11, 2016, 10:16:06 am »

TolyK is clearly scum for trying to appear too townie with his necroing threads comment.  Also, he's just shifty.

Yeah, wincon checking is essentially checking a number of triggers.  Pardon the sloppy-ass pseudocode.  It's been over a decade since I did anything non-assembler.
For some common cases:  Mafia win if (mafiapeeps >= nonmafiapeeps) and (no_non_mafia_killers() == true)
Survivors win if (game_state_someone_won() == true) and (survivor_alive() == true)
SKs win if (players_alive() == 1) and (SK_alive() == true)

Alternatively, if each player is a class ... hmm, no that idea won't work.  I was going to say that each player's wincon could be a pointer to a linked list of other players who are blocking said player's wincon (and said players are removed from said list as they die), but that won't work for checking a survivor's wincon.  Could be tweaked perhaps?  Maybe have different wincon classes?  Like a death_wincon would be like I described above, but you can also have a doom_wincon class which checks the current day value against it's threshold value.  Survivor_wincon checks to see if a "someone won" flag has been set. 


In so far as abilities are concerned, I think you might need to break that up into different ability classes or something as well.  Would a PGO's ability fit with your defined ability class?  Or any reactive ability, really. 

Just to look at the Xylbot role list for some tricky ability implementations:  Beta Werewolf, Super-Saint, Eavesdropper, Forensics Expert, Gunsmith, Astrologer, etc.

Also a lot of conditional abilities like tracking, watching, delayer, CPR doctor, etc. ...

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #6 on: March 11, 2016, 12:51:01 pm »

It's been over a decade since I did anything non-assembler.
... I'll just let this one slide.

Quote from: Shakerag
For some common cases:  Mafia win if (mafiapeeps >= nonmafiapeeps) and (no_non_mafia_killers() == true)
Survivors win if (game_state_someone_won() == true) and (survivor_alive() == true)
SKs win if (players_alive() == 1) and (SK_alive() == true)
Well, if you have basic wincons like this, it might work.

Quote from: Shakerag
Alternatively, if each player is a class ... hmm, no that idea won't work.  I was going to say that each player's wincon could be a pointer to a linked list of other players who are blocking said player's wincon (and said players are removed from said list as they die), but that won't work for checking a survivor's wincon.  Could be tweaked perhaps?  Maybe have different wincon classes?  Like a death_wincon would be like I described above, but you can also have a doom_wincon class which checks the current day value against it's threshold value.  Survivor_wincon checks to see if a "someone won" flag has been set.
I think this is thinking a bit too low-level. See below.

Quote from: Shakerag
In so far as abilities are concerned, I think you might need to break that up into different ability classes or something as well.  Would a PGO's ability fit with your defined ability class?  Or any reactive ability, really. 

Just to look at the Xylbot role list for some tricky ability implementations:  Beta Werewolf, Super-Saint, Eavesdropper, Forensics Expert, Gunsmith, Astrologer, etc.

Also a lot of conditional abilities like tracking, watching, delayer, CPR doctor, etc. ...
I'd prefer making a system where each "extra" ability can just be added on content.

I was thinking more around generating "events" (actual or pseudo), which wincons and other triggers can subscribe to.
Or rather, that "triggers" can subscribe to, and wincons incorporate those triggers. So would triggered abilities.

For those you mentioned:

Beta Werewolf: Subscribe to "kill" events. If criteria (is night & target is Alpha) met, cancel the event.
Super-Saint: Kill last to vote, doesn't seem too hard - just look at vote queue.
Eavesdropper: Eeeh... I wouldn't want to use this in nearly any setup, but technically: Subscribe to message send events, then unsub at end of night.
Forensics Expert: Dead players are still in the game. Likely either the mod processes the actual role text, or it could be a % chance per ability?
Gunsmith: This is kinda iffy in terms that just this role requires "extra information" on the type of kill.

Hmm.

For several of these (notably Gunsmith), would require extra information to be added to each role OR for a list of "gun roles" to be incorporated into the Gunsmith role (in the checker). However, for most it actually seems like an Event-driven architecture would be optimal.

Yes, in a role-heavy game it helps to encorporate the triggers into a list of things to check at each action resolution.

So I've been working on a balanced role generator partly inspired by your chart that modularises the use phase/ability/target type. Adding weights to the elements and adding flaws/buffs accordingly. Still very much a work in progress, but these are the sorts of roles it's been spitting out:

(Night)(Target/Self) You can protect. All protects against you fail.

(Night)(Target 1-2) You can block. Your abilities have a 50% chance of targeting yourself.

(Anytime)(Target) You can kill. You die if your vote is on a town player when they are lynched. You have 50% chance of giving your ability away to a random player after each lynch.
Wouldn't it make a bit more sense to generate roles with several abilities? As in, the third one would be:

(Anytime)(Target) You can kill.
(Auto) You die if your vote is on a town player when they are lynched.
(Auto) You have 50% chance of giving your ability away to a random player after each lynch.

[You could say this is one guilt-feeling vigilante :P]
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #7 on: March 11, 2016, 01:53:27 pm »

Alright, did some more drawing.

Spoiler: Updated Big Picture (click to show/hide)
Spoiler: Wincon Scheme (click to show/hide)

Ability type blatantly ripped off of Magic the Gathering, because I basically arrived at the same idea and keeping terminology the same is probably for the better. :P
Also because it seems to encompass all (the vast majority) of possible actions an... actor can take.


Edit:
Spoiler: Event System (Basics) (click to show/hide)
1. Objects subscribe to events
2. Events can be broadcast by any object (usually only abilities, wincons and game states)
3. Things happen, cased by the subscribers.

Ordering between subscribers is also decided by Priority. For example, for two conflicting Auto abilities ("prevent further kills" and "kill killer", which trigger on the same thing (a day kill), their response (as Actions) are placed in the resolution queue based on their priority. Oh crap, that's the next thing to draw.
« Last Edit: March 11, 2016, 02:22:41 pm by TolyK »
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #8 on: March 11, 2016, 02:59:30 pm »

Alright, added an example for how an Auto ability would work in response to an action.


Also, I just realized that in this scheme there's no way to "cancel" an action from occurring, i.e. preventative maintenance roles or roleblocks.
Maybe Events are broadcast before they occur so they can be Canceled? Ideas?


The more I think about this, the more I'm guessing I'll be implementing in C# (as opposed to C++ or Java), since its event structure is best known to me. :P
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

webadict

  • Bay Watcher
  • Former King of the Mafia
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #9 on: March 20, 2016, 08:24:02 am »

Alright, added an example for how an Auto ability would work in response to an action.


Also, I just realized that in this scheme there's no way to "cancel" an action from occurring, i.e. preventative maintenance roles or roleblocks.
Maybe Events are broadcast before they occur so they can be Canceled? Ideas?


The more I think about this, the more I'm guessing I'll be implementing in C# (as opposed to C++ or Java), since its event structure is best known to me. :P
The way to stop an action before it happens is to follow a list of ability types. You can gather every action, run them in order from higher priority to lowest priority, and then work from there.

I'd be willing to help with this, too. I like programming this stuff.
Logged

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #10 on: March 20, 2016, 09:05:56 am »

Yes, I have a priority set for every action. However, some Triggered (some Auto) abilities (such as "if there would be a death, prevent it if it's the first one this phase") would add additional actions and/or cancel the current action.
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

webadict

  • Bay Watcher
  • Former King of the Mafia
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #11 on: March 20, 2016, 09:17:32 am »

Yes, I have a priority set for every action. However, some Triggered (some Auto) abilities (such as "if there would be a death, prevent it if it's the first one this phase") would add additional actions and/or cancel the current action.
That seems like you're having that action at the same time as the kill ability, then. If it just listens to the kill action, it should be able to modify those actions.
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #12 on: March 20, 2016, 10:32:13 am »

PTW.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #13 on: March 20, 2016, 02:47:21 pm »

Yes, I have a priority set for every action. However, some Triggered (some Auto) abilities (such as "if there would be a death, prevent it if it's the first one this phase") would add additional actions and/or cancel the current action.
That seems like you're having that action at the same time as the kill ability, then. If it just listens to the kill action, it should be able to modify those actions.
The thing is, modifying actions on-the-go is pretty hard (or requires a lot of spaghetti code, or special cases, or whatever). So is monitoring if "someone died" and reviving them... Other than that, I've actually coded quite a bit of it.
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

webadict

  • Bay Watcher
  • Former King of the Mafia
    • View Profile
Re: Mafia Theory: Game Structure
« Reply #14 on: March 20, 2016, 06:21:34 pm »

Yes, I have a priority set for every action. However, some Triggered (some Auto) abilities (such as "if there would be a death, prevent it if it's the first one this phase") would add additional actions and/or cancel the current action.
That seems like you're having that action at the same time as the kill ability, then. If it just listens to the kill action, it should be able to modify those actions.
The thing is, modifying actions on-the-go is pretty hard (or requires a lot of spaghetti code, or special cases, or whatever). So is monitoring if "someone died" and reviving them... Other than that, I've actually coded quite a bit of it.
Mind if I have a look? I think I can help.
Logged
Pages: [1] 2