kingmaker 0.1.0

A modular, performant, social choice framework for the simulation, computation, and analysis of strategic voting.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::core::{Candidate, Method, Ordinal, Profile, SingleWinner};

/// A single-winner ranked voting method. The winner is determined by selecting a random ballot and returning the winner(s) of that ballot. That ballot is the only ballot that matters, hence the title "random dictator".
#[derive(Debug, Clone, serde::Serialize)]
pub struct RandomDictator;

impl Method for RandomDictator {
    type Ballot = Ordinal;
    type Winner = SingleWinner;
    fn outcome(&self, candidates: &[Candidate], profile: Profile<Self::Ballot>) -> Self::Winner {
        if profile.is_empty() {
            return SingleWinner::None;
        }
        let winner = profile[0][0];
        SingleWinner::win(candidates, winner)
    }
}