• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Mafia Player-Role List Generator - a command-line program - 22nd May

1,235
Posts
10
Years
  • Seen Jun 17, 2017
I had this blog post pretty much ready to post, but my browser crashed when I opened a link in another tab and now it's all gone :( Anyway here's a shorter version since I don't feel like typing it all again


To practice C++, I wanted to actually make a program. I decided to make a simple little command-line program for Mafia GMs that takes in names of players, names of roles, and then randomly assigns the roles to players, and generates a list to be used by the GM.

But don't worry, you don't have to type in all the names and roles into the program - it reads all that data from .txt files!

You can download the .rar - which includes the executable, as well as the necessary .txt files (which you must edit) - here.


You use the program by:

-In "names.txt", inputting the name of each player, seperated by line.
-In "innocentSpecial.txt", inputting the name of each Innocent Special role, seperated by line.
-In "mafiaSpecial.txt", inputting the name of each Mafia Special role, seperated by line.
-Running the program.
-Specifying the total amount of Mafia players (including Special roles).
-Specifying whether or not there is an unaffiliated player (program currently only supports one unaffiliated faction that can contain only one player).
-The program will then generate the list, and save it to the file "listOutput.txt".

More detailed information on how to use the program is available in the readme included in the package, and I recommend you read it before you use the program :).


The program does work, however I would still consider it a prototype due to the fact that the random generation is done with a PRNG using the current Unix time as a seed, where it would be optimal for the program to source its random numbers from random.org. As such, it is unfit for proper use by a GM, unless that GM is okay with pseudo-random results for their role assignment.



-Cosmic
 
1,235
Posts
10
Years
  • Seen Jun 17, 2017
Klippy;bt102903 said:
*would Like comment, but no Likes for blog comments*

So thanks :D It really helped me learn by making it, stuff like reading data from files and dynamically allocating variables.
 
1,235
Posts
10
Years
  • Seen Jun 17, 2017
gimmepie;bt102905 said:
Oh wow this is awesome! I can't wait to see the finished version. :D
Melody;bt102906 said:
A finished version maybe should properly implement the random.org API, so you get true randomness!
Thank you! Finishing it would involve adding the random.org API, and I'm not fully sure how to do that currently, but it would be helpful if the library is portable. I am going to try :)

arachnidsGrip;bt102907 said:
totally gonna use the final version on the next few games i host :3
:D
 

Lycanthropy

[cd=font-family:Special Elite;font-size:16px;color
11,037
Posts
10
Years
Awesome! I programmed something like this on my calculator a few years ago, but inputting names and roles works a lot better on a computer, certainly when it can read text files. Good job!
 
1,235
Posts
10
Years
  • Seen Jun 17, 2017
Lycanthropy;bt102909 said:
Awesome! I programmed something like this on my calculator a few years ago, but inputting names and roles works a lot better on a computer, certainly when it can read text files. Good job!
Thank you! On a calculator :O?
 
Back
Top