Skip to content

Instantly share code, notes, and snippets.

@maksverver
Created December 10, 2022 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maksverver/ee2ee796a814cdb5acaa18644a6e0947 to your computer and use it in GitHub Desktop.
Save maksverver/ee2ee796a814cdb5acaa18644a6e0947 to your computer and use it in GitHub Desktop.
@@ -349,7 +350,8 @@
//int minx = 0, miny = 0, maxx = 0, maxy = 0;
BitGrid grid;
- int numCells = 0;
+ grid.Set(0, 0);
+ int numCells = 1;
while (ptr < end)
{
@@ -364,17 +366,18 @@
{
int d = dir;
Move lastMove;
- for (int k = 0; k < NumKnots; k++)
+ for (int k = 0; k < NumKnots && d != None; k++)
{
auto& state = knotStates[k];
lastMove = States[state][d];
state = lastMove.nextState;
d = lastMove.moveDir;
}
- x += lastMove.dx;
- y += lastMove.dy;
-
- numCells += grid.Set(x, y);
+ if (d != None) {
+ x += lastMove.dx;
+ y += lastMove.dy;
+ numCells += grid.Set(x, y);
+ }
}
}
tsimulate.Stop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment