Differences From Artifact [98744373e0968733]:
- File        
src/solver.d
- 2012-07-15 02:37:41 - part of checkin [c2c105fda0] on branch trunk - Support 'G' at any timing. (user: kinaba) [annotate]
 
To Artifact [ede3d182d99f2de5]:
- File        
src/solver.d
- 2012-07-15 04:44:33 - part of checkin [879099f815] on branch trunk - Moved 'abort' behavior completely out of Game. (user: kinaba) [annotate]
 
    1  import util;                                                                           1  import util;
    2  import game;                                                                           2  import game;
    3                                                                                         3  
    4  class Solver_0                                                                         4  class Solver_0
    5  {                                                                                      5  {
    6          this(const(Game) g) {}                                                   |     6          this(in Game g) {}
    7          char single_step() { return 'W'; }                                             7          char single_step() { return 'W'; }
    8          void force(char c) {}                                                          8          void force(char c) {}
    9  }                                                                                      9  }
   10                                                                                        10  
   11  class Solver_1                                                                        11  class Solver_1
   12  {                                                                                     12  {
   13          int wait_count = 0;                                                           13          int wait_count = 0;
   14          int choke_count = 0;                                                          14          int choke_count = 0;
   15                                                                                        15  
   16          Game g;                                                                       16          Game g;
   17          this(const(Game) g)                                                      |    17          this(in Game g)
   18          {                                                                             18          {
   19                  this.g = g.clone();                                                   19                  this.g = g.clone();
   20                  forbidden_cell = new bool[][](g.map.H+2, g.map.W+2);                  20                  forbidden_cell = new bool[][](g.map.H+2, g.map.W+2);
   21          }                                                                             21          }
   22                                                                                        22  
   23          char single_step()                                                            23          char single_step()
   24          {                                                                             24          {
   25                  Tuple!(string,int) de = death_move(g);                                25                  Tuple!(string,int) de = death_move(g);
   26                  char c = act(g, de[0], de[1]);                                        26                  char c = act(g, de[0], de[1]);
   27                  g.command(c);                                                    |    27                  force(c);
   28                  return c;                                                             28                  return c;
   29          }                                                                             29          }
   30                                                                                        30  
   31          void force(char c)                                                            31          void force(char c)
   32          {                                                                             32          {
                                                                                        >    33                  if(c != 'A')
   33                  g.command(c);                                                    |    34                          g.command(c);
   34          }                                                                             35          }
   35                                                                                        36  
   36          Tuple!(string,int) death_move(const(Game) g)                                  37          Tuple!(string,int) death_move(const(Game) g)
   37          {                                                                             38          {
   38                  string death;                                                         39                  string death;
   39                  int choice = 0;                                                       40                  int choice = 0;
   40                  foreach(char c; "UDLRW") {                                            41                  foreach(char c; "UDLRW") {