W      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ -Simplistic role data structure and instances.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneINOThe Loner allegiances are seldom used, rather they are present for correctness.uRole definitions require only a few pieces of information. Most of the game logic behind a role is implemented in Game.Werewolf.Command and Game.Werewolf.Engine.The balance attribute on a role indicates the allegiance it favours. For example, a Simple Werewolf has a balance of -4 while the Seer has a balance of 2. A balance of 0 means it favours neither allegiance.+N.B., role equality is defined on just the   as a role's # may change throughout the game. 5A list containing all the roles defined in this file.EA list containing roles that are restricted to a single instance per Game.   =   \\ [, ] ;A list containing all the allegiances defined in this file.+TODO (hjw): use reflection to get this list\Abandoned in the woods by his parents at a young age, he was raised by wolves. As soon as he \learned how to walk on all fours, the Wild-child began to wander around Miller's Hollow. One Vday, fascinated by an inhabitant of the village who was walking upright with grace and [presence, he made them his secret role model. He then decided to integrate himself into the ]community of Miller's Hollow and entered, worried, in the village. The community was moved by Yhis frailty, adopted him, and welcomed him in their fold. What will become of him: honest ZVillager or terrible Werewolf? For all of his life, the heart of the Wild-child will swing Sbetween these two alternatives. May his model confirm him in his newfound humanity.wOn the first night, the Wild-child may choose a player to become his role model. If during the game the chosen player is eliminated, the Wild-child becomes a Werewolf. He will then wake up the next night with his peers and will devour with them each night until the end of the game. However for as long as the Wild-child's role model is alive, he remains a Villager.XAll dogs know in the depths of their soul that their ancestors were wolves and that it's Zmankind who has kept them in the state of childishness and fear, the faithful and generous ]companions. In any case, only the Wolf-hound can decide if he'll obey his human and civilized Gmaster or if he'll listen to the call of wild nature buried within him.gOn the first night, he chooses if he wants to be a Simple Villager or Werewolf. The choice is final.[The muddy life of a village infested with evil creatures repulses him; he wishes to believe \he's the victim of a terrible nightmare, in order to finally wake up in his comfortable bed.When the Angel is in play, the game always begins with the village's debate followed by an elimination vote, and then the first night.The Angel wins if he manages to get eliminated on the first round (day or night). If he fails, then he becomes a Simple Villager for the rest of the game.\Ah! How sweet it is, in my memory, the sound of chains slipping onto the cobblestones of the ]"Three Road" plaza, accompanied by the grunting of Ursus. Ah! How long ago it was that Titan, [the Bear Tamer, would lead his companion in a ballet so gravious that we'd cry every summer [in Miller's Hollow. Ursus even had the oh-so-previous ability to detect lycanthropes hidden  near him.Each morning, right after the revelation of any possible nocturnal victims, if at least one Werewolf is or ends up directly next to the Bear Tamer, then Ursus grunts to indicate danger to all of the other players.FThis character can save the Villagers from the bite of the Werewolves.Each night the Defender is called before the Werewolves to select a player deserving of his protection. That player is safe during the night (and only that night) against the Werewolves.\It's sad to say, but in Miller's Hollow, when something doesn't go right it's always him who "unjustly suffers the consequences.\If the village's vote ends in a tie, it's the Scapegoat who is eliminated instead of no-one.In this event, the Scapegoat has one last task to complete: he must choose whom is permitted to vote or not on the next day.TA fortunate teller by other names, with the ability to see into fellow townsfolk and determine their allegiance.BEach night the Seer sees the allegiance of a player of her choice.ZA simple, ordinary townsperson in every way. Their only weapons are the ability to analyze Ubehaviour to identify Werewolves, and the strength of their conviction to prevent the +execution of the innocents like themselves.VWhat is a village without an idiot? He does pretty much nothing important, but he's so ,charming that no one would want to hurt him.If the village votes against the Village Idiot, his identity is revealed. At that moment the Villagers understand their mistake and immediately let him be.kThe Village Idiot continues to play but may no longer vote, as what would the vote of an idiot be worth?YThis person has a soul as clear and transparent as the water from a mountain stream. They Zwill deserve the attentive ear of their peers and will make their word decisive in crucial moments.When the game begins, the village is told the identity of the Villager-Villager, thus ensuring certainty that its owner is truly an innocent Villager.XShe knows how to brew two extremely powerful potions: a healing potion, to resurrect the \player devoured by the Werewolves, and a poison potion, used at night to eliminate a player.The Witch is called after the Werewolves. She is allowed to use both potions in the same night and is also allowed to heal herself.[Each night they devour a Villager. During the day they try to hide their nocturnal identity to avoid mob justice.-A Werewolf may never devour another Werewolf.The counter-part to !, but more general as it takes a  instead.A re-write of  to be more general by taking a  instead.A companion to M that, rather than using a predicate, filters on the given lens for matches.&     %Response and message data structures.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone0 =A message may be either public or private, indicated by it's to field.Each message contains a single text field. This field is permitted to contain special characters such as new lines and tabs.!The message recipient:  for a public message,  for a private message."The message text.##When a user sends a command to the werewolf' binary, a response is always returned.0The chat client interface should then relay any messagesN from the response. Whether or not the command was valid (indicated by the ok. flag) is often irrelevant as the returned messages! will include errors to the user.%!Boolean flag to indicate success.&List of messages.'A successful, empty response.( An unsuccessful, empty response.)PExits fast with the given response. The response is encoded as JSON, printed to stdout( and then the program is exited with 0 (success).The program always exits with success even if the response was a failure one. This is to distinguish between bad calls to the binary and bad commands to the werewolf engine.*-Creates a public message with the given text.+ privateMessage to messageCreates a private message to to with the given text., groupMessages tos messageLCreates multiple private messages (1 to each recipient) with the given text. !"#$%&'()*+, !"#$%&'()*+,#$%&'() !"*+,  !"#$%&'()*+,uSimplistic player data structure with functions for searching, filtering and querying lists of players.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47IN$-"Surprise surprise, players may be / or ..0A player has a 1, 2 and 32. Any stateful information needed for a player's role is held on the Game itself.-N.B., player equality is defined on just the 1.6Creates a new . player.7The traversal of 0 s with an . 7 = 2 .   8The traversal of 0 s with a . 8 = 2 .   9The traversal of 0 s with a . 9 = 2 .   :The traversal of 0 s with a . : = 2 .   ;The traversal of 0 s with a . ; = 2 .   <The traversal of 0 s with a . < = 2 .   =The traversal of 0 s with a . = = 2 .   >The traversal of 0 s with a . > = 2 .   ?The traversal of 0 s with a . ? = 2 .   @The traversal of 0 s with a . @ = 2 .   AThe traversal of 0 s with a . A = 2 .   BThe traversal of 0 s with a . B = 2 .   CThe traversal of 0s aligned with the . C = 2 .  .   DThe traversal of 0s aligned with the . D = 2 .  .   EThis  provides the traversal of 0 names. E =  . 1 FThis  provides the traversal of 0 roles. F =  . 2 GThis  provides the traversal of 0 states. G =  . 3 HThis  provides the traversal of 7 0s. H =  .  ( 7) IThis  provides the traversal of 8 0s. I =  .  ( 8) JThis  provides the traversal of 9 0s. J =  .  ( 9) KThis  provides the traversal of : 0s. K =  .  ( :) LThis  provides the traversal of ; 0s. L =  .  ( ;) MThis  provides the traversal of < 0s. M =  .  ( <) NThis  provides the traversal of = 0s. N =  .  ( =) OThis  provides the traversal of > 0s. O =  .  ( >) PThis  provides the traversal of ? 0s. P =  .  ( ?) QThis  provides the traversal of @ 0s. Q =  .  ( @) RThis  provides the traversal of A 0s. R =  .  ( A) SThis  provides the traversal of B 0s. S =  .  ( B) TThis  provides the traversal of C 0s. T =  .  ( C) UThis  provides the traversal of D 0s. U =  .  ( D) VThis  provides the traversal of . 0s. V =  ( $ 3 . 4) WThis  provides the traversal of / 0s. W =  ( $ 3 . 5) 0-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW.-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW.0123-./456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW*-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWPGame data structure with functions for manipulating and querying the game state.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone"X Events occur after a \2 is advanced. This is automatically handled in  7, while an event's specific behaviour is defined by   and  .DFor the most part events are used to allow something to happen on a \2 different to when it was triggered. E.g., the  DeovurEvent~ occurs after the village wakes up rather than when the Werewolves' vote, this gives the Witch a chance to heal the victim.Y WerewolvesZDefender, Werewolves and Witch[Witch\<Most of these are fairly self-sufficient (the turn stages). a and bS are provided as meaningful breaks between the day and night as, for example, a d? may not always be available (curse that retched Scapegoat).2Once the game reaches a turn stage, it requires a  d to help push it past. Often only certain roles and commands may be performed at any given stage.iVThere are a few key pieces of information that a game always needs to hold. These are:the y,the v number,the p andthe l.Any further fields on the game are specific to one or more roles (and their respective turns!). Some of the additional fields are reset each round (e.g., the Seer's xM) while others are kept around for the whole game (e.g., the Wild-child's u).In order to advance a game's 3, a  Y from a user needs to be received. Afterwards the following steps should be performed:   the  .run  .run . g will perform any additional checks and manipulations to the game state before advancing the game's y. It also runs any relevant l. Y will check to see if any of the win conditions are met and if so, advance the game's y to ]. Wolf-hound ScapegoatWitchWitchWitchWitchWitchDefenderDefender Wild-child ScapegoatSeer Village IdiotVillagers and Werewolves All of the \&s in the order that they should occur.An infinite cycle of all \&s in the order that they should occur.4Checks whether the stage is available for the given is. Most often this just involves checking if there is an applicable role alive, but sometimes it is more complex./One of the most complex checks here is for the d'. If the Angel is in play, then the dF is available on the first day rather than only after the first night.Creates a new iQ with the given players. No validations are performed here, those are left to .Kills the given player! This function should be used carefully as it doesn't clear any state that the player's role may use. If you're after just removing a player from a game for a test, try using a  instead. Gets all the k? in a game (which is names only) and maps them to their player. Gets all . players that have yet to vote.Gets all players that had theh highest vote count. This could be 1 or more players depending on whether the votes were in conflict.  game = game ^. v == 0*Queries whether the player is in the game.Queries whether anyone has won.pQueries whether the Angel has won. The Angel wins if they manage to get themselves killed on the first round.&N.B., we check that the Angel isn't a C5 as the Angel's role is altered if they don't win.Queries whether the  have won. The / win if they are the only players surviving.Queries whether the  have won. The / win if they are the only players surviving.TXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~AXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Aiyvplojkmnqrstuwxz{\]^_`abcdefgh}|~XYZ[2XYZ[\ ]^_`abcdefghijklmnopqrstuvwxyz{|}~+Suite of messages used throughout the game.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone;     )     ;     $Utility functions for working in a ( i) environment.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47INFudges the player's allegiance. This function is useful for roles such as the Wild-child where they align themselves differently given some trigger." !"#$%&'()*+,-./0123456" !"#$%&'()*+,-./0123456" !"#$%&'()*+,-./0123456Engine functions.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47 789:;<= 789:;<=Command data structure.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47IN>?>?+Re-exports all of the public modules under  Game.Werewolf.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~@ !"#$%&'()*+,-./012234556789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~    Ay      !"#$%&'()*+,-./0123456789:;<=>?@  ABCwerew_AkKf9d5QsBFIbGZEgVIn18Game.Werewolf.RoleGame.Werewolf.ResponseGame.Werewolf.PlayerGame.Werewolf.GameGame.Werewolf.EngineGame.Werewolf.CommandControl.Lens.Prismisn't checkStageeventAvailable applyEventCommandapply checkGameOver startGame quitCommandGame.Werewolf.MessagesGame.Werewolf.Util Game.Werewolf AllegianceAngel Villagers WerewolvesRoleadvice allegiancebalance descriptionname_Angel _Villagers _WerewolvesallRolesrestrictedRolesallAllegiances wildChildRole wolfHoundRole angelRole bearTamerRole defenderRole scapegoatRoleseerRolesimpleVillagerRolevillageIdiotRolevillagerVillagerRole witchRolesimpleWerewolfRoleis filteredByMessagetomessageResponseokmessagessuccessfailureexitWith publicMessageprivateMessage groupMessagesStateAliveDeadPlayerrolestate_Alive_Dead newPlayerangel bearTamerdefender scapegoatseersimpleVillagersimpleWerewolf villageIdiotvillagerVillager wildChildwitch wolfHoundvillagerwerewolfnamesrolesstatesangels bearTamers defenders scapegoatsseerssimpleVillagerssimpleWerewolves villageIdiotsvillagerVillagers wildChildrenwitches wolfHounds villagers werewolvesalivedeadEvent DevourEvent NoDevourEvent PoisonEventStageGameOver DefendersTurnScapegoatsTurn SeersTurnSunriseSunset UrsussGrunt VillagesTurnWerewolvesTurnWildChildsTurn WitchsTurnWolfHoundsTurnGameallegianceChosen allowedVoterseventshealhealUsedpassesplayerspoison poisonUsed priorProtectprotect roleModelroundscapegoatBlamedseestagevillageIdiotRevealedvotes _GameOver_DefendersTurn_ScapegoatsTurn _SeersTurn_Sunrise_Sunset _UrsussGrunt _VillagesTurn_WerewolvesTurn_WildChildsTurn _WitchsTurn_WolfHoundsTurn _DevourEvent_NoDevourEvent _PoisonEvent allStages stageCyclestageAvailablenewGame killPlayergetAllowedVotersgetPendingVoters getVoteResult isFirstRounddoesPlayerExist hasAnyoneWon hasAngelWonhasVillagersWonhasWerewolvesWonchooseAllegianceCommandchoosePlayerCommandchoosePlayersCommand circleCommand healCommand noopCommand passCommand pingCommand poisonCommandprotectCommand seeCommand statusCommandvoteDevourCommandvoteLynchCommandlens_2cH2us51VaEJEqkl1SW1lGControl.Lens.GetterGettingControl.Lens.Foldfiltered_name _allegiance_balance _description_advice$fEqRolebaseGHC.BaseNothingJust$fToJSONMessage$fFromJSONMessage$fToJSONResponse$fFromJSONResponseonlyControl.Lens.Type TraversalData.Traversabletraversehas_role_state $fEqPlayer_allegianceChosen_allowedVoters_heal _healUsed_passes_poison _poisonUsed _priorProtect_protect _roleModel_scapegoatBlamed_see_villageIdiotRevealed_votes_stage_round_players_eventsnewGameMessagesnewPlayersInGameMessagenewPlayerMessagevillagerVillagerMessage stageMessagesdefendersTurnMessagesscapegoatsTurnMessagesseersTurnMessagessunriseMessagenightFallsMessagefirstVillagesTurnMessagesvillagesTurnMessagesfirstWerewolvesTurnMessageswerewolvesTurnMessageswildChildsTurnMessageswitchsTurnMessageswolfHoundsTurnMessagesgameOverMessagesplayerWonMessageplayerLostMessageplayerQuitMessagegameIsOverMessageplayerDoesNotExistMessageplayerCannotDoThatMessage!playerCannotDoThatRightNowMessageplayerIsDeadMessagetargetIsDeadMessage circleMessagepingPlayerMessagepingRoleMessagecurrentStageMessagesrolesInGameMessageplayersInGameMessagewaitingOnMessageangelJoinedVillagersMessageursusGruntsMessage/playerCannotProtectSamePlayerTwiceInARowMessage"scapegoatChoseAllowedVotersMessage'playerMustChooseAtLeastOneTargetMessage%playerCannotChooseVillageIdiotMessageplayerSeenMessageplayerMadeLynchVoteMessageplayerLynchedMessagenoPlayerLynchedMessagescapegoatLynchedMessagevillageIdiotLynchedMessageplayerHasAlreadyVotedMessageplayerMadeDevourVoteMessageplayerDevouredMessagenoPlayerDevouredMessage(playerCannotDevourAnotherWerewolfMessageplayerJoinedPackMessagewildChildJoinedPackMessagesplayerCannotChooseSelfMessageplayerPoisonedMessageplayerHasAlreadyHealedMessageplayerHasAlreadyPoisonedMessageallegianceDoesNotExistMessagearticlemtl_Aue4leSeVkpKLsfHIV51E8Control.Monad.State.Class MonadStatesetPlayerAllegiance findPlayerBy_getAdjacentAlivePlayers getPassers getPlayerVoteisDefendersTurn isGameOverisScapegoatsTurn isSeersTurn isSunriseisVillagesTurnisWerewolvesTurnisWildChildsTurn isWitchsTurnisWolfHoundsTurnisPlayerDefenderisPlayerScapegoat isPlayerSeerisPlayerVillageIdiotisPlayerWildChild isPlayerWitchisPlayerWolfHoundisPlayerWerewolf isPlayerAlive isPlayerDead checkStage' lynchVotees devourVotees advanceStage checkEventsvalidatePlayervalidateWitchsCommand