GithubHelp home page GithubHelp logo

ecashin / nextspeaker Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 4.62 MB

Somewhat fair command-line next-speaker selector

License: Other

Rust 6.01% HTML 0.07% SCSS 0.04% Shell 0.08% CSS 59.58% Sass 34.22%

nextspeaker's Introduction

NEXTSPEAKER

NEXTSPEAKER is a speaker chooser, selecting a speaker from a list of participants.

Goals

  • Be unpredictable
  • Avoid choosing too-recently chosen speakers
  • Avoid neglecting to choose participants for too long
  • Avoid aggressively focusing on new members of the participant group
  • Avoid administrative work (like recording when members join, etc.)

Building

To compile and use this Rust software, you can install rustup and use cargo as desired, e.g., as shown below.

Usage

Create two text files.

  • A list of participants, one name per line, without duplicates
  • A list of previous selections, one name per line

Example

There are two text files.

bash$ wc -l *.txt
9 history.txt
21 participants.txt
30 total
bash$ sed 3q participants.txt 
Alice
Abram
Adam
bash$ sed 3q history.txt 
Edith
Earnie
Estelle

We review the usage.

bash$ cargo run -- --help
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/nextspeaker --help`
Usage: nextspeaker [OPTIONS] <PARTICIPANTS>

Arguments:
  <PARTICIPANTS>

Options:
      --history <HISTORY>
      --history-halflife <HISTORY_HALFLIFE>  [default: 10]
  -h, --help                                 Print help information
bash$

The next speaker is selected.

bash$ cargo run -- participants.txt --history history.txt
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
    Running `target/debug/nextspeaker participants.txt --history history.txt`
Alice
bash$ 

We record the selection in the history.

bash$ echo Alice >> history.txt

History

The core selection algorithm here is based on the memoradical flashcards app.

Balancing the entire-history per-participant selection rate might not always be ideal. New participants would not always be selected, but they'd be favored heavily. To avoid overwhelming newcomers to the group, a "half life" is used to make the historical effect of participation decay over time. The default half life is ten selections.

Simulation

A statistician would say that this program is fair "in expectation." You might happen to get results that seem unfair toward a participant who does or doesn't want to get chosen. To help provide a feel for the kind of results you can expect, there's a simulation mode, where you specify how many times the program is used in the simulation.

The output shows each participant with a count of the number of times that participant was selected. By running the program 1000 times and seeing what would have happened, one can get a feel for what the selected settings are doing.

Here is an example.

bash$ cat participants.txt
Alice
Abram
Adam
Barbara
Ben
Bob
Carl
Cassandra
Charli
David
Debora
Doug
Edith
Earnie
Estelle
Francis
Franklin
Frederick
Gladys
Gabriel
Gayle
bash$

Note from the history that Earnie has had many turns, but they were concentrated in the past.

bash$ cat history.txt
Earnie
Earnie
Earnie
Earnie
Earnie
Earnie
Earnie
Earnie
Earnie
Earnie
Edith
Earnie
Estelle
Earnie
Earnie
Francis
Franklin
Frederick
Gladys
Gabriel
Gayle
bash$

With the default half-life of ten events, Earnie is selected in the 1000 simulated runs 1.6% of the time.

bash$ cargo run -- --history history.txt --n-simulations 1000 participants.txt
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/nextspeaker --history history.txt --n-simulations 1000 participants.txt`
     Alice: 64
     Abram: 86
      Adam: 75
   Barbara: 67
       Ben: 46
       Bob: 66
      Carl: 60
 Cassandra: 64
    Charli: 68
     David: 67
    Debora: 59
      Doug: 65
     Edith: 55
    Earnie: 16
   Estelle: 39
   Francis: 45
  Franklin: 58
 Frederick: 0
    Gladys: 0
   Gabriel: 0
     Gayle: 0
bash$

If that seems unfair, you can cause the effect of history to last longer. Increasing the half life to 100 below makes Earnie less likely to be selected. In this second simulation, Earnie is chosen 0.9% of the time, down from 1.6% when using the default half life.

bash$ cargo run -- --history history.txt --n-simulations 1000 --history-halflife 100 participants.txt
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/nextspeaker --history history.txt --n-simulations 1000 --history-halflife 100 participants.txt`
     Alice: 64
     Abram: 69
      Adam: 75
   Barbara: 66
       Ben: 55
       Bob: 74
      Carl: 54
 Cassandra: 72
    Charli: 67
     David: 74
    Debora: 67
      Doug: 72
     Edith: 56
    Earnie: 9
   Estelle: 39
   Francis: 40
  Franklin: 47
 Frederick: 0
    Gladys: 0
   Gabriel: 0
     Gayle: 0
bash$

Logging

To gain insight into how NEXSPEAKER is working, you can examine the source code and run with the RUST_LOG environment variable set to info or even debug.

This environment variable controls the verbosity of the logging output.

Web Demo

There is a much simplified version of this tool available at the URL below. It uses default settings. Local web storage makes the data you enter persist for each of your browsers.

Click Here for Demo

nextspeaker's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.