Ai Dreams Forum

Member's Experiments & Projects => General Project Discussion => Topic started by: Zero on January 05, 2018, 09:45:09 am

Title: PRO|STAMINA
Post by: Zero on January 05, 2018, 09:45:09 am
 
Hi,

I've just realized that I forgot to drop a link to a pet programming game I made several months ago 

It's called PRO|STAMINA. It's a tennis themed betting game where two programs compete in duels.

The program that makes the best predictions of the other program's behavior wins the game. So... who has the deepest learning algorithm?

Tell me what you think. http://pro-stamina.atspace.eu/
Title: Re: PRO|STAMINA
Post by: Zero on January 05, 2018, 10:01:26 am
Here are 3 bots to start with.

Kickass.js
Code
var previous = [0,'Love',0,0,'Love',0];

var opGameplay = {};

var myComment = 'Go!';


onmessage = function(e) {

   
    var workerResult;
 
    if (e.data=='play') { workerResult = 2; } else {

        learn(e);
       
        previous = [
            e.data.me.force,
            e.data.me.point,
            e.data.me.game,
            e.data.opponent.force,
            e.data.opponent.point,
            e.data.opponent.game
        ];
       
        myComment = ' ';
       
        var opGuess = guess();
       
        if (opGuess > 5) {
           
            workerResult = 1;
           
        } else {
           
            workerResult = opGuess+1;
           
        }       
    }
   
    postMessage(workerResult+myComment);
}



function learn(e) {
   
    for (var i=0; i<6; i++) {
   
        var situation = e.data.opponent.force+'<='+i+'=='+previous[i];
       
        if (!opGameplay[situation]) {
           
            opGameplay[situation] = 1;
           
        } else {
           
            opGameplay[situation] += 1;
           
        }
    }
}



function guess() {
   
    var best = 0;
    var bestValue = 0;
    var value;

    for (var testForce=1; testForce<10; testForce++) {
       
        value = 0;
   
        for (var i=0; i<6; i++) {
           
            var situation = testForce+'<='+i+'=='+previous[i];
           
            if (opGameplay[situation]) { value += opGameplay[situation]; }
           
        }
       
        myComment += '['+testForce+']='+value+', ';
       
        if (value >= bestValue) {
           
            bestValue = value;
           
            best = testForce;
           
        }
    }   
   
    return best;
}

Smartass.js
Code
onmessage = function(e) {

  var myComment = '';

  var workerResult;
 
  if (e.data=='play') { workerResult = "1"; } else {
     
      workerResult = e.data.opponent.force+1;
 
      if (e.data.me.force > e.data.opponent.force) { myComment = "Wooo yeah!"; } else { myComment = "ok..."; }
  }
 
  postMessage(workerResult+' '+myComment);
}

Randy
Code
onmessage = function(e) {

  var workerResult = 1+(Math.random()*3);
  postMessage(workerResult+' '+Math.floor(10000000*Math.random()));
}
Title: Re: PRO|STAMINA
Post by: ivan.moony on January 05, 2018, 12:03:21 pm
I like the graphic design.
Title: Re: PRO|STAMINA
Post by: Zero on January 05, 2018, 02:27:27 pm
Thanks! I tried something futuristic... green from The Matrix, blue from Tron, and red from Roland Garros.  ;)

So... can you beat Kickass.js gentlemen?