Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sadale: amigojapan_bnc, maybe this. First roll a die. If n>=4, adds 5 to the next die. Otherwise it's 0. After that, roll the die again. If n<= 5, add n
- //with the previous value. If n==6, reroll.
- //[01:39am] Sadale: amigojapan_bnc, after this process, you get one digit.
- //[01:40am] Sadale: So to get 4 digits, you need to throw 4 times, or more if you encounter 6.
- //this can be used to make arbitrary numbers
- function getDiceRoll() {//I tested that it generates 1 to 6 by for(i=0;i<10000;i++)if(getDiceRoll()==1) console.log("has 1");
- return Math.round(Math.random() * (6 - 1) + 1);
- }
- function getDigit(){
- var ret = 0;
- if(getDiceRoll() >= 4){
- ret += 5
- }
- while(true) {
- var value = getDiceRoll();
- if(value <= 5) {
- ret += value;
- if(ret == 10){ // NEW CONDITION!!
- ret = 0
- }
- return ret;
- }
- }
- }
- for(i=0;i<100;i++){
- console.log(getDigit());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement