JSFiddle - React, Tailwind, and code Playground

by path411

HTML

<script src="http://download.basecase.com/programming-test/defender.js"></script>

JavaScript

/*
  This AI simply generates a random 'plan'.

  Update the 'notify_player()' function to implement your own AI.
*/

defender.start(
  function notify_player(rocks, paddle_y){
    // random plan
    var moves = [];
    for( var i = 0; i < 22; i++ ){
      // -1, 0, 1
      moves.push( Math.floor(Math.random()*3) - 1 );
    }
    return moves;
  }
);