JSFiddle - React, Tailwind, and code Playground
by Jon-Carlos Rivera
JavaScript
function r(g){with(Math){return['tie','lose','win'][-(~~(log(g.length-3)/LN2) - ~~(random()*3) - 3)%3];}}
// Let's test it!
['rock','paper','scissors'].forEach(function(move){
var a = [];
for(var i = 0; i< 25000; i++) a.push(r(move));
var losses = a.filter(function(v){ return (v === 'lose'); }).length;
var draw = a.filter(function(v){ return (v === 'tie'); }).length;
var wins = a.filter(function(v){ return (v === 'win'); }).length;
console.log(move, 'wins:', wins, 'draws:', draw, 'losses:', losses);
});