Development of voting bot that can distribute voting weights by ranking

Words
517
Reading
3 min
9y
Listen to this post
~3 min

You know I'm working on Steemhunt project these days, and we just launched our sponsor program yesterday (REF: Introducing Incentives for Steemhunt Sponsors).

We have 23,051 SP delegated so far on day 1, and we can already see the traction is happening! 🙌🏻

To distribute those voting power to Steemhunt users evenly, we had to develop a voting bot that can calculate a voting weight on each post by our daily ranking.

The criteria we set as follow:

  • Vote on every post, except the ones that doesn't meet our guidelines
  • Voting weight varies depending on the ranking
  • Use 20% of voting power per day
    (voting with 100% power costs 2%, so 1000% voting power in total)

At first, I thought it would be an easy math, but soon I realized it is more difficult than I thought..


(Evidence I was struggling with remembering high school math for a long time... facepalm)

The first method

I tried was using a sequence, solving those 2 equations


when

  • x = voting power that nth post would get
  • a = initial voting power (when n = 1)
  • b = weight gap between nth and n-1th postings
  • t = total number of posts we need to handle

and I got the simple equation:

AND.. failed

because when I set the maximum of initial weight (a), the minimum weight can go below zero. I could still just use it if I set the minimum weight first instead of maximum, and limit the maximum weight to 100%. But in that case, we would waste some amount of voting power everyday..

I thought I could do it better if I use 2nd dimension graph instead of just linear one, but it was a huge waste of time.. because I suck at math..

So I decided to do it in a programmer way:

 

This is basically just making a fixed length array filled with average weights (1000 / total number of posts), and add and deduct the same amount of weight from the first & last elements.

Problem solved.

However, it was not enough. When there're hundreds of posts I need to vote, those linear distribution would be almost same as 1/n. We wanted to incentivize more for top hunters.

At the end, I had to use exponential function (Softmax).

Do you remember Euler's number?

I couldn't even remember how to read it anymore.. lol

Luckily, one of my genius PHD friends helped me out:

Look at how disgusting an equation can get.. 😨
It's called Softmax function (normalized exponential function), and I only knew about it yesterday (It seems that method is being used in Neural Networks and Deep Learning shit..).

Anyway my friend kindly coded the draft up for me:

(All thanks to SangWoong!)

and the final code I wrote in ruby is following:

I don't understand 100%.. but it's working very nicely 😂

I tuned the temperature variable to make the graph as steep as possible.
and the final results for today's votings:

I hope my posting is useful for someone in the future, so they don't waste so much time like me :)

Cheers to all Steem devs.

Development of voting bot that can distribute voting weights by ran... | Ecency