&& currentCoords.y > initialCoords.y) dragged = true;
    else if(expectedDirection === 'left' && currentCoords.x < initialCoords.x) dragged = true;
    else if(expectedDirection === 'right' && currentCoords.x > initialCoords.x) dragged = true;

    var r = dragged ? 1.0 : -1.0;
    core.endEpisode(r, r>0);
  });
}

var genProblem = function() {
  // clear the UI.
  var svg = d3.select('svg');
  svg.selectAll('*').remove();

  var expectedDirection = core.sample(DIRECTIONS);
  d3.select('#query').html('Drag