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

20D Ago
I wrote this for BitPeople ([]( 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++; }