0
\$\begingroup\$

Following this question, I need a sandbox to try out the StackOverflow API for grabbing code from answers.

Please do not post answers to this question.

<script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><h2>Dwarf</h2><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>Score</th> </tr></thead> <tbody id="clients"> </tbody></table><script type='text/javascript'>  
league_table.dwarf.forEach( function(data_row){var row=$('<tr>'); var cell=$('<td>'); cell.html(data_row.name.substring(6)); row.append(cell); cell=$('<td>'); cell.html(data_row.win); row.append(cell); cell=$('<td>'); cell.html(data_row.lose); row.append(cell);row.append(cell);cell=$('<td>'); cell.html(data_row.score); row.append(cell); $('tbody#clients').append(row);});</script>

\$\endgroup\$
12
  • \$\begingroup\$ I'm here to add a comment to help you ensure that your code works even with comments posted \$\endgroup\$
    – Mathgeek
    Mar 4 '20 at 14:50
  • \$\begingroup\$ Thanks @Mathgeek. It shouldn't matter too much because I'm filtering out the comments, but it can't hurt to have a little noise here. \$\endgroup\$
    – AJFaraday
    Mar 4 '20 at 14:51
  • \$\begingroup\$ I tried a similar thing once and it caught comments instead of the answer once there were enough, so I figured an extra lob wouldn't hurt. \$\endgroup\$
    – Mathgeek
    Mar 4 '20 at 14:54
  • \$\begingroup\$ I am also here just to make it a bit harder for no obvious reason ... \$\endgroup\$
    – Veljko89
    Mar 5 '20 at 14:45
  • \$\begingroup\$ If anyone's interested, the comments did not cause any problems with my importing process. \$\endgroup\$
    – AJFaraday
    Mar 5 '20 at 15:42
  • \$\begingroup\$ Then one with a code block: f=_=>{throw 'AJFaraday';} :) \$\endgroup\$
    – Bubbler
    Mar 6 '20 at 8:26
  • \$\begingroup\$ @Bubbler You make a good point. I'm working on a fairly-paranoid importer script which should throw out answers which risk messing up the competition environment. \$\endgroup\$
    – AJFaraday
    Mar 6 '20 at 9:21
  • 1
    \$\begingroup\$ "Please ignore this question" tends to attract attention. Perhaps try "Stack Exchange API sandbox"? You can also go ahead and remove the first sentence. This is the perfect place to do this. \$\endgroup\$
    – S.S. Anne
    Mar 10 '20 at 22:30
  • \$\begingroup\$ I've VTCed this as the challenge has now been posted and this question is no longer needed. \$\endgroup\$
    – Shaggy
    Jul 10 '21 at 1:24
  • \$\begingroup\$ I've agreed with Shaggy, and VTCed. If you need this Sandbox again, I suggest mentioning this in chat for it to be reopened \$\endgroup\$ Jul 12 '21 at 1:54
  • \$\begingroup\$ I had meant to delete these to save you the effort, but apparently I'm not able to because of Shaggy's answer. Sorry. \$\endgroup\$
    – AJFaraday
    Jul 12 '21 at 8:14
  • 2
    \$\begingroup\$ I’m voting to close this question because it's my old one which I do not need any more. I'm creating a new similar one, and would use this instead except that there's answers from other people so I'm not allowed to delete it. \$\endgroup\$
    – AJFaraday
    Jul 20 '21 at 11:22
2
\$\begingroup\$

Imported

class {
  constructor(controller, utils) {
    this.controller = controller;
    this.side = controller.side;
    this.utils = utils;
  }

  turn() {
    var target = this.controller.previous_move().to;
    var troll = this.controller.space_info(target.x, target.y).nearest_troll.pieces[0];
    this.controller.select_space(troll.x, troll.y);
    var space_info = this.controller.check_space(troll.x, troll.y);
    var closest_move = this.utils.closest_to(space_info.moves, target);
    this.controller.move(closest_move.x, closest_move.y);
  }

  end_turn() {
    var scores = this.controller.scores();
    this.controller.declare(scores.winning == 't');
  }

}
\$\endgroup\$
2
  • \$\begingroup\$ Care to add a Try It Online? \$\endgroup\$
    – user92069
    Mar 6 '20 at 1:00
  • \$\begingroup\$ I could, although it would prove very little. Just that Behaviours is undefined. \$\endgroup\$
    – AJFaraday
    Mar 6 '20 at 9:18
1
\$\begingroup\$

MoreJunk

throw 'ha ha haaa!';
\$\endgroup\$
1
\$\begingroup\$

Invalid

class {
  constructor(controller, utils) {
    this.controller = controller;
    this.side = controller.side;
    this.utils = utils;
  }

  turn() {
    // Oops! nothing here!
  }

  end_turn() {

  }

}
\$\endgroup\$
1
\$\begingroup\$

Imported_duplicate

class {
  constructor(controller, utils) {
    this.controller = controller;
    this.side = controller.side;
    this.utils = utils;
  }

  turn() {
    var target = this.controller.previous_move().to;
    var troll = this.controller.space_info(target.x, target.y).nearest_troll.pieces[0];
    this.controller.select_space(troll.x, troll.y);
    var space_info = this.controller.check_space(troll.x, troll.y);
    var closest_move = this.utils.closest_to(space_info.moves, target);
    this.controller.move(closest_move.x, closest_move.y);
  }

  end_turn() {
    var scores = this.controller.scores();
    this.controller.declare(scores.winning == 't');
  }

}

Posting at AJ's request.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .