Hacker News new | ask | show | jobs
by elwell 4650 days ago
I find the translate function, though very simple, rather elegant JS:

  AI.prototype.translate = function(move) {
   return {
      0: 'up',
      1: 'right',
      2: 'down',
      3: 'left'
    }[move];
  }
Ref: https://github.com/ov3y/2048-AI/blob/master/js/ai.js#L230