Giter Club home page Giter Club logo

randompicker's Introduction

RandomPicker

简书中文

Idea:💡

Pseudo-random. There are some songs in your play list, each song's weight is 1 in the first. Each time you click the next button, each song's weight increases by 1, and the selected song's weight returns to 0. The song's weight is positively correlated with the chance of being picked.

- Love Story 东风破 Refrain Tassel
sequence weight weight weight weight picked
1 1 1 1 1 东风破
2 2 0 2 2 Love Story
3 0 1 3 3 Refrain
4 1 2 0 4 Tassel
5 2 3 1 0 Love Story
6 0 4 2 1 Tassel
7 1 5 3 0 东风破
8 2 0 4 1 Love Story
9 0 1 5 2 Tassel
10 1 2 6 0 ...
...

Demo

RandomPicker

How to use

Quick start:

RandomPicker randomPicker = new RandomPicker(12);
int nextPos = randomPicker.next();

More function:

randomPicker.setMultiplyNumber(3);
randomPicker.setAddNumber(2);
randomPicker.setNextPick(5);
randomPicker.add();
randomPicker.changeOriginWeight(0,3);
randomPicker.getHistoryList();

More functions: download this repo and take a look at the code.

Compile

The latest version

add this to the project level build.gradle file

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

add the dependency to the app level build.gradle file

// replace {x.y.z} with the latest version.
compile 'com.github.XunMengWinter:RandomPicker:{x.y.z}'

p.s. If you have any suggestions for improvement, please discuss on issues or pull requests.

randompicker's People

Contributors

lpmi-13 avatar xunmengwinter 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.