i love modding but i'm a lazy idiot, so naturally the obvious answer was to write a vote counter. I figured that could help other people who are still counting votes by hand, so I figured what the hell, tossed it on github. for now it's just a votecounter lol but in the future i might add more stuff to it, especially if there's demand for it.
"but osuka, how is this different from all the other vote counters out there?" great question, thank you for asking.
most of the vote counters i've ever seen are web-based. This comes with a few downsides:
- it costs $$$ to run a server, so they probably won't run forever
- servers may have downtime
- servers may be overloaded, which could make the votecounter painfully slow
i've seen some vote counters that are not hosted on a server but instead a downloadable executable. that's cool too, but it does also come with a few downsides:
- platform support may be limited (what if it's a windows binary, but i'm on macOS or linux?)
- they may be largely inflexible (how are the posts formatted? how does the parser work?)
- they may not be updated in time (are they actively maintained?)
the votecounter was built with correctness in mind - it will
always
give you the exact same output if given the exact same input. That means things like multiple votes in a single post are resolved in the same way, every time. the votecounter guarantees:
- it will always resolve votes the same way
- it will only resolve votes that it's sure (or almost sure) are correct - otherwise, it's designed to fail and require human intervention to protect game integrity and ensure correctness
- it will always warn if it's not
really
sure of a vote
The only drawback, so far, is that
it will not count bolded votes - only votes in vote tags. If there is demand to change this, I will.
this votecounter is written in python. it's effectively infinitely extensible, by virtue of being FOSS (free + open source software) - it's MIT licensed, so go nuts - and easily maintainable by anyone with working knowledge of Python. it's also auditable by anyone with working knowledge of python, so you can rest assured it's not gonna pwn you and steal your credit card number and family pictures.
I opted for a CLI (command-line interface) utility instead of a graphical interface. This means the code is simpler to write and maintain, it's more lightweight, and it can run (basically) anywhere. if you're not a wiz or if you've never used a CLI in the past, fret not! Here are a few tips to get you started, depending on your platform. Remember you only need to run setup once!
Spoiler: windows
Spoiler: setup
if you're on windows, you should have powershell already installed - it ships with the OS. You'll need git and python - the easiest way to install these, to me, is with chocolatey. You can follow the instructions on that page, under "individual", to install it. Once you've installed chocolatey, start powershell as admin and run:
now that we're done installing our dependencies, navigate to the folder you want to download the vote counter to. For example, if I want to download it into a folder called "mafiascum" under my documents folder:
cd C:\Users\osuka\Documents\mafiascum\mafiascum-modtools
python ./votecounter.py mygamedefinition.yaml --template osuka.jinja
you should also keep it up to date! to make sure you have the latest version, make sure your terminal is in the folder you downloaded the votecounter and run:
if you're on macOS, i cannot recommend homebrew highly enough. open up the Terminal - that's where you'll install brew - and once you've got homebrew installed, run the following:
then, navigate to the folder you want to download the votecounter to and download it. For example, let's say I want to download it to a folder called "mafiascum" under my Documents folder:
now that we're done installing dependencies and getting the votecounter, write your game definition file and optionally, your formatting template, and you should be good to go. For example, I'd run:
cd ~/documents/mafiascum/mafiascum-modtools
python3 ./votecounter.py mygamedefinition.yaml --template osuka.jinja
you should also keep it up to date! to make sure you have the latest version, make sure your terminal is in the folder you downloaded the votecounter and run:
todo lmao if you're on linux i assume you probably know how to use the cli. install git and python3, then install the dependencies as shown in the github page. i'll prob write this at some point in the future lol sorry
also, most of the vote counters i've ever seen assume certain things about how post #0 is formatted or other things. I don't like that, so i decided to build a solution that worked for me in the way i wanted it to. the votecounter works with a game definition file - the specifications of which can be found in the github page, as well as an example of a game definition file. Writing the game definition is a one-off - when you do it, you shouldn't have to do it again for the same game, and it should take only a few minutes to set that up. After that, it's just a matter of running the votecounter and letting it do its thing.
But wait! there's more!
It also optionally formats posts for you! I'm a lazy shit and i don't wanna format posts by hand, so the votecounter uses Jinja to format posts in whatever way you want them to be formatted and just outputs the phpBB code for the post, (mostly) ready to go. There's also an example of this, as well as some more details, in the github page.
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
please please please let me know how this works for you! what do you want to see? what sucks? what doesn't suck?
if you have problems with the setup or if you find something wrong with it, please let me know! i want this to be useful to more people than just myself so don't be afraid to ask or complain!
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
how good is the username string matching algorithm you are using btw?
I gave up trying to write my own votecounter because I couldn't find a satisfactory solution without resorting to extensive configs, or venturing to NLP category (despair)
i think the CLI format is pretty user friendly already, but might still pose as a barrier to entry for a lot of non tech-savvy people, one step further u can take is a browser extension so people can install on Chrome/Firefox and it can make modifications to the DOM directly while in the mafiascum.net domain
I think jacksonvirgo was tryna do that, not sure how thats going now tho
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
how good is the username string matching algorithm you are using btw?
I gave up trying to write my own votecounter because I couldn't find a satisfactory solution without resorting to extensive configs, or venturing to NLP category (despair)
i think the CLI format is pretty user friendly already, but might still pose as a barrier to entry for a lot of non tech-savvy people, one step further u can take is a browser extension so people can install on Chrome/Firefox and it can make modifications to the DOM directly while in the mafiascum.net domain
I think jacksonvirgo was tryna do that, not sure how thats going now tho
i can patch it to use ppp - i didn't know that existed. good call!
the votecounter uses jellyfish's implementation of jaro-winkler similarity, but with a
very
high confidence threshold. it's designed to fail if it can't decide with almost near-certainty what a vote is - i wrote it that way to protect the integrity of the game and make sure that if there is a need for human intervention, that happens at the earliest possible moment rather than waiting until the moderator realizes something is wrong.
the fuzzy matching is Good Enough(tm) - it's not groundbreaking and, by design, it doesn't try all that hard to match a vote. it does fuzzy match aliases, though, so if there's a vote for an alias of a player and
that
has a typo, it should still work fine
i don't wanna do a browser extension because that's a whole lot of extra work that i don't think is gonna be all that helpful to begin with. userscript could work?
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
your linux instructions reminds me of a time i saw a project that had instructions for various distros and for gentoo it was like "you can probably figure it out on your own tbh"
In post 9, Psyche wrote:
i have a pretty solid username matcher that i basically finetuned through brute force. is even in python! will share when i have the time
you should be able to patch that in relatively quickly
do you think there would be interest in importing the username matcher implementation as a module? that way if someone wants their vote counter to be more/less strict, then the counter logic itself and the formatting stuff still work, with any arbitrary implementation of a name matcher
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
Yeah, it's always been something that has come down to user preference. For my use case, it was important to be really flexible since game moderators have generally been really flexible in their votecounting.
Here's the code (very messy). I will need to remind myself of how it works, but it's like 20 if statements in a sequence that I was able to validate as reliably predicting the final flip for each day phase across ~2-300 games (who was limmed, and at what post number).
Much of it is just different applications of edit distance or educated guesses about how people will abbreviate usernames. A particularly involved trick I used is was to apply a spellchecker library to generate all possible segmentations of usernames into valid English words (in my english_divides function). This information makes it easier to predict certain kinds of abbreviations/misspellings people will use when more obvious cues like spaces/capitalizations aren't available.
A little refactoring should make it fit into your library. When I get the time...
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
speaking of which, something that might be useful for adoption might be a webapp that people can play with to try it out. i once had something like that running in a google colab notebook
In post 15, Psyche wrote:
speaking of which, something that might be useful for adoption might be a webapp that people can play with to try it out. i once had something like that running in a google colab notebook
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
In post 18, Random Nurse wrote:
For laypeople like me how exactly do I get this running? I have an HP laptop that uses Windows.
were the instructions in #0 hard to follow?
I'm not familiar with using Github.
you shouldn't have to open github at all, unless you want to look at the code on your browser. Look for the spoilers in #0 - I'll quote them here but i'll also note for any future readers that this may be out of date, so you should check the OP for the most up-to-date instructions
if you're on windows, you should have powershell already installed - it ships with the OS. You'll need git and python - the easiest way to install these, to me, is with chocolatey. You can follow the instructions on that page, under "individual", to install it. Once you've installed chocolatey, start powershell as admin and run:
now that we're done installing our dependencies, navigate to the folder you want to download the vote counter to. For example, if I want to download it into a folder called "mafiascum" under my documents folder:
cd C:\Users\osuka\Documents\mafiascum\mafiascum-modtools
python ./votecounter.py mygamedefinition.yaml --template osuka.jinja
you should also keep it up to date! to make sure you have the latest version, make sure your terminal is in the folder you downloaded the votecounter and run:
if you have any questions about the instructions or any of the steps
please
let me know - i come from a technical background and i'm knee-deep in a terminal on the daily, so the real test of whether my instructions suck or not is someone who's
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi
In post 22, JacksonVirgo wrote:
Has been a month since the last post so I'm sorry for the useless bump but I am egoposting here from the depths of hell. I have arisen
no worries - i do watch the thread to try and help anyone who wants to use it
"I would also like to reiterate my claim that Osuka is sort of obviously town" - rc about scumsuka
"don't tell anyone, but there's a reason why you're one of my favourite people to mod for" - datisi