Tamper-proof Tibia lotteries

Warning: This blog post is unrelated to Tibian map exploration. But, if you’re a Tibia player, it might still be interesting to you — especially if you care about Tibia item lotteries or if you’re just curious to hear some tips on how to be a good lottery host. Let’s dive in!

Here’s a fun thought experiment: let’s say you wanted to organize a lottery. How can you guarantee that the result of your lottery is fair and randomly decided, and that you had no way of influencing the outcome?

All lotteries require a certain amount of trust in the organizer. After all, you pay for your lottery ticket with the expectation that the organizer will eventually deliver the prize to the rightful winner (as opposed to, say, taking the money and disappearing). Ultimately, there is no way to completely avoid trust. (For that reason, you should never participate in a lottery organized by someone you don’t trust — duh.)

However, honest organizers can significantly reduce the amount of trust required from their lottery participants. As an organizer, there are steps you can take to guarantee that the lottery draw is fair and truly random, and that there is no way for you or anyone else to influence the result.

Think about it — many Tibia lotteries don’t currently have this guarantee. When a lottery draw happens as part of some live-stream, for example, who’s to say you’re really watching a live stream and not some pre-made recording that happens to show the organizer’s preferred ticket number? For those of us with trust issues, there is simply no way to tell 🥲

Luckily, there are solutions to this problem.

Solution #1: using tibiamaps/lottery

I recently built a hobby project that offers one particular solution to this problem. It’s a fully open-source script that generates cryptographically strong numbers, and publishes them on a daily basis. Crucially, the script doesn’t run on anyone’s local machine (where people could potentially mess with the environment or just change the script itself to influence the results in their favor) — instead, it runs entirely in the cloud. No one can change the script without committing those changes to the repository, which would leave traces that would be publicly visible forever. For more details, check out the project’s README on GitHub.

To organize a provably fair lottery, you could follow the project’s instructions. Basically, you’d refer to one of the project’s files where new random numbers are added once per day — e.g. from-01-to-50.txt for a lottery with 50 tickets. Then you pick any future date as the date of the draw. Finally, you publicly announce both the file + date. Then you just wait for the date to come, and for the random number to be added to the file. That random number determines the winner, in a way that can easily be verified by all participants. Huzzah! 🎉

Solution #2: using random.org

After I built all this, Nohus pointed out that random.org actually supports a similar feature. It’s possible to construct a URL like this:

https://www.random.org/integers/?num=1&col=1&base=10&min=1&max=50&format=html&rnd=date.2022-07-21

That is, we tell random.org to give us a single random number from 1 to 50 based on the date 2022-07-21. In this particular case, the result is:

Here are the numbers, generated with randomization from 2022-07-21:
35

Timestamp: 2022-07-21 20:41:55 UTC

Note how it doesn’t produce new random numbers every time you load the page. Instead it consistently shows you the one random number based on your requirements for that specific day. This way, any participant can verify the result just by visiting the same URL.

Note how changing the date in the URL to some date in the future e.g. 2099-12-31 results in an error:

Error: No randomization exists for that date

The random.org service won’t generate that date’s random number until that page is requested on or after that date. This is perfect, because it means we can safely choose any future date for the winner to be drawn, without there being any way to spoil or predict the result.

The way to make use of this is similar to the earlier solution: once all lottery tickets have been sold, pick a date in the future (e.g. the next day). Then publicly announce that date and post the corresponding random.org URL following the above format. When the day comes (UTC), visit the URL to reveal the winning ticket.

Recommendations

Don’t force your lottery participants to blindly trust anyone to perform a fair draw, when there is simply no need to do so! This article discussed two different ways to solve this problem.

Conceptually, the two approaches (tibiamaps/lottery vs. random.org) are similar. tibiamaps/lottery has the benefit of being fully transparent and open-source. On the other hand, random.org has the benefit of not being controlled by anyone even remotely related to Tibia (at least not as far as we know), which perhaps makes it easier to trust as a neutral party.

Whenever hosting a Tibia lottery, consider using one of these two options. It really doesn’t matter which one.

Thoughts? Comments? Join the discussion about this article on Reddit.

Ferumbras’ hat lottery hosted by TibiaMaps.io

TibiaMaps.io is hosting a Ferumbras’ hat lottery on Antica, in which we’ll apply our own advice from this article. For more info, or to participate in the lottery, see Tibia forum thread #4926569. Good luck!

You see Ferumbras’ hat (Arm:1). Classification: 4 Tier: 0. It weighs 8.50 oz. It is the proof that Ferumbras has fallen. For now. The Edron Academy should be interested in this.

Update @ 2022-08-06: By 2022-08-05, all lottery tickets had been sold and paid for, so we could schedule the lottery draw for the next day i.e. 2022-08-06 — just 15 days after starting the lottery. Thanks to all the participants, and congratulations to Henkentica for winning the hat!

This was the first time TibiaMaps.io hosted a lottery, but given the success of this one, we might do so again in the future.

Update @ 2023-06-05: We’re now hosting our second lottery! The prize is the same — a Ferumbras’ hat — except the hat is located on Vunira this time. Vunira is a Yellow BattlEye Open PvP server (just like Antica).

Update @ 2023-06-24: We’re now hosting another lottery on Antica! The prize is the same — a Ferumbras’ hat. Good luck to all participants!

Here’s an overview of lotteries we’ve hosted.