• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Vote System?

Status
Not open for further replies.
Level 4
Joined
Jun 19, 2007
Messages
53
I've given so many frustrating hours to this idea that I'm turning to the professionals. I've been trying to build a vote-dialog system, and I'm stuck on determining a winner. Its all about the numbers. There are 8 options to vote for, so a binary system is out of the question. Also, I'd like to avoid using a daisy-chain of IF statements. Has anyone had any success in finding an easy way to do this?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,208
What sort of vote is this... Gradual or abrupt?
Gradual for difficulties where if someone votes easy and another hard you get a medium difficulty out.
Abrupt like elections where you vote for 1 of many options and which ever scores the most wins.

With gradual, you are just after getting the average vote result by asigning all buttons numbers with a linear gradient, summing and deviding by vote number.

With abrupt you use a maximum algerthim to find whatever got the most votes. If there is a tie you need to eithor revote or randomly choose.
 
Level 4
Joined
Jun 19, 2007
Messages
53
Its an abrupt system of 8 options, and can you please be a bit more specific?
My old system was:

  • Locals:
  • Integer i
  • Integer r
  • Integer winner
  • Actions:
  • Pick each integer (1 thru 8):
    • set i = i + 1
    • Pick each integer(1 thru 8):
      • set r = r + 1
      • IF
        • Votes[i] > votes[r]
          • i != r
      • THEN
        • set winner = i
Its not the most effective system(especially since it doesn't work...), but I can't find any workarounds.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,208
Arrays start at 0 and go to size-1. Thus an array of size 8 will have indicies of 0 to 7 (inclusive). Player 0 is not playable so players will go from 1 to some number.

Have some pesudo code...

number = 0
max = 0
while number < array.size{
if array[number] > array[max]{
max = number
}
number++
}
//Code here that uses the value in max which is the index of the most votes.
 
Status
Not open for further replies.
Top