MultiversX Tracker is Live!

Clever, and seemingly different, voting mechanism for voters to agree on a number between 0 and n

Etherum Reddit

More / Etherum Reddit 102 Views

I wrote this for BitPeople (https://bitpeople.org). I thought for years about how to agree by majority vote on a number in a range of numbers. The classical is to vote for one, and hope others do too. But, anyone sees issue with that. This one "nudges" the result in a direction, and resists change if target is ever reached. I do not know if this is a new idea or if similar solutions have been developed decades ago. It is new to me at least.

mapping (address => uint) public voteToken; uint max; uint result; mapping (uint => uint) votes; uint counter; // Votes in a way that approaches the target _vote, // your vote inches closer to _vote by one, // and resists change once _vote is reached, // changing from positive to negative or vice versa function vote(uint _vote) external { require(_vote <= max); require(voteToken[msg.sender] >= 1); voteToken[msg.sender]--; votes[_vote]+=2; uint res = result; if(_vote > res) { if(counter < votes[res]) counter++; else { require(res < max); result++; counter = 0; } } else if(_vote < res) { if(counter > 0) counter--; else { require(res > 0); result--; counter = votes[res-1]; } } else counter++; } 
submitted by /u/johanngr
[link] [comments]
Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments