1
\$\begingroup\$

Testing ground for the answer importer on this proposed challenge (dwarf edition)

https://codegolf.meta.stackexchange.com/a/23556/16824

Please do not answer this question!


I am using this question as a mock to write code to import entries into the KotH challenge against. My development instance is pulling answers from this question to ensure everything works before I go live.

Once the challenge goes live, the answers will be imported from one of two questions on the main Code Golf site.

\$\endgroup\$
3
  • \$\begingroup\$ what's this question? \$\endgroup\$
    – mathcat
    Jun 29 '21 at 13:42
  • \$\begingroup\$ @math It's just a question for me to test a code importer against, so that I can hopefully take a hands-off approach and let the script move entries around for me. I've added a brief description. \$\endgroup\$
    – AJFaraday
    Jun 29 '21 at 13:51
  • \$\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:23
1
\$\begingroup\$

baby_steps_duplicate

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

  turn() {
    var dwarf = this.controller.dwarfs()[0];
    if(dwarf) {
      var moves = this.controller.check_space(dwarf.x, dwarf.y).safe_moves;
      if(moves[0]) {
        this.controller.select_space(dwarf.x, dwarf.y);
        this.controller.move(moves[0].x, moves[0].y);
      } else {
        this.call_it_a_day();
      }
    } else {
      this.call_it_a_day();
    }
  }

  call_it_a_day() {
    this.it_is_a_day = true;
    this.controller.declare(true);

    var dwarf = this.controller.dwarfs()[0];
    var space_info = this.controller.check_space(dwarf.x, dwarf.y);
    this.controller.select_space(dwarf.x, dwarf.y);
    this.controller.move(space_info.moves[0].x, space_info.moves[0].y);
  }

  end_turn() {
    var scores = this.controller.scores();
    this.controller.declare(this.it_is_a_day || scores.winning == 'd');
  }

}

Posting at AJ's request.

\$\endgroup\$
0
\$\begingroup\$

baby steps

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

  turn() {
    var dwarf = this.controller.dwarfs()[0];
    if(dwarf) {
      var moves = this.controller.check_space(dwarf.x, dwarf.y).safe_moves;
      if(moves[0]) {
        this.controller.select_space(dwarf.x, dwarf.y);
        this.controller.move(moves[0].x, moves[0].y);
      } else {
        this.call_it_a_day();
      }
    } else {
      this.call_it_a_day();
    }
  }

  call_it_a_day() {
    this.it_is_a_day = true;
    this.controller.declare(true);

    var dwarf = this.controller.dwarfs()[0];
    var space_info = this.controller.check_space(dwarf.x, dwarf.y);
    this.controller.select_space(dwarf.x, dwarf.y);
    this.controller.move(space_info.moves[0].x, space_info.moves[0].y);
  }

  end_turn() {
    var scores = this.controller.scores();
    this.controller.declare(this.it_is_a_day || scores.winning == 'd');
  }

}
\$\endgroup\$

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