Anonymous avatar Anonymous committed d99c576

Placed more stuff into _add_next_state.

Comments (0)

Files changed (1)

abc-path/generator/generate-abs-path.pl

 }
 
 
-sub _get_next_state
+sub _add_next_state
 {
-    my ($self, $l, $cell_int) = @_;
+    my ($self, $stack, $l, $cell_int) = @_;
 
+    vec($l, $cell_int, 8) = 1+@$stack;
     my $cells = $self->_get_next_cells($l, $cell_int);
     $self->_fisher_yates_shuffle($cells);
 
-    return [$l, $cells];
+    push @$stack, [$l, $cells];
+
+    return;
 }
 
 use List::Util qw(first);
 {
     my $self = shift;
 
-    my $init_xy = $self->{rand}->range_rand($BOARD_SIZE);
-
-    my $init_layout = '';
-    vec($init_layout, $init_xy, 8) = 1;
-
-    my @dfs_stack = ($self->_get_next_state($init_layout, $init_xy));
+    my @dfs_stack;
+    $self->_add_next_state(\@dfs_stack, '', $self->{rand}->range_rand($BOARD_SIZE));
 
     DFS:
     while (@dfs_stack)
             }
         }
 
-        my $next_layout = $l;
-        vec($next_layout, $next_idx, 8) = 1+@dfs_stack;
-
-        push @dfs_stack, $self->_get_next_state($next_layout, $next_idx);
+        $self->_add_next_state(\@dfs_stack, $l, $next_idx);
     }
 
     die "Not found!";
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.