private void Constrain( bool exitEast, bool exitNorth, bool exitWest, bool exitSouth, System.Random r) { _constraintState.Init(); // left cage _constraintState.ConstrainLoc(3, 3, 11); // right cage _constraintState.ConstrainLoc(4, 3, 12); if (exitEast) { // pick a loc with x=7, open East var y = r.Next(8); _constraintState.SetWall(7, y, MovementDirection.EAST, IsWall.NO); } if (exitWest) { // pick a loc with x=0, open West var y = r.Next(8); _constraintState.SetWall(0, y, MovementDirection.WEST, IsWall.NO); } if (exitNorth) { // pick a loc with y=0, open North var x = r.Next(8); _constraintState.SetWall(x, 0, MovementDirection.NORTH, IsWall.NO); } if (exitSouth) { // pick a loc with y=7, open South var x = r.Next(8); _constraintState.SetWall(x, 7, MovementDirection.SOUTH, IsWall.NO); } MakeEmptyBox(0, 0, 7, 7); MakeEmptyBox(1, 1, 6, 6); MakeEmptyBox(2, 2, 5, 5); MakeEnclosingBox(1, 1, 6, 6); MakeEnclosingBox(2, 2, 5, 5); switch (_randomGenerator.Next(4)) { case 0: _constraintState.ConstrainLoc(3, 4, 3); _constraintState.ConstrainLoc(4, 4, 2); break; case 1: _constraintState.ConstrainLoc(3, 4, 2); _constraintState.ConstrainLoc(4, 4, 3); break; case 2: _constraintState.ConstrainLoc(3, 4, 6); _constraintState.ConstrainLoc(4, 4, 6); break; case 3: _constraintState.ConstrainLoc(3, 4, 9); _constraintState.ConstrainLoc(4, 4, 9); break; } var ory = _randomGenerator.Next(1, 4); _constraintState.SetWall(0, ory, MovementDirection.EAST, IsWall.NO); _constraintState.SetWall(7, ory, MovementDirection.WEST, IsWall.NO); _constraintState.SetWall(0, 7 - ory, MovementDirection.EAST, IsWall.NO); _constraintState.SetWall(7, 7 - ory, MovementDirection.WEST, IsWall.NO); var orx = _randomGenerator.Next(1, 4); _constraintState.SetWall(orx, 0, MovementDirection.SOUTH, IsWall.NO); _constraintState.SetWall(orx, 7, MovementDirection.NORTH, IsWall.NO); _constraintState.SetWall(7 - orx, 0, MovementDirection.SOUTH, IsWall.NO); _constraintState.SetWall(7 - orx, 7, MovementDirection.NORTH, IsWall.NO); var irx = _randomGenerator.Next(2, 4); _constraintState.SetWall(irx, 1, MovementDirection.SOUTH, IsWall.NO); _constraintState.SetWall(irx, 6, MovementDirection.NORTH, IsWall.NO); _constraintState.SetWall(7 - irx, 1, MovementDirection.SOUTH, IsWall.NO); _constraintState.SetWall(7 - irx, 6, MovementDirection.NORTH, IsWall.NO); _constraintState.Tighten(); }
private void AddInitialConstraintState( bool exitEast, bool exitNorth, bool exitWest, bool exitSouth, System.Random r) { var s = new ConstraintState(); s.Init(); // left cage s.ConstrainLoc(3, 3, 11); // right cage s.ConstrainLoc(4, 3, 12); if (exitEast) { // pick a loc with x=7, open East var y = r.Next(8); s.SetWall(7, y, MovementDirection.EAST, IsWall.NO); if (_lrSymmetry) { // and then with x = 0, open West s.SetWall(0, y, MovementDirection.WEST, IsWall.NO); } } else if (exitWest) { // pick a loc with x=0, open West var y = r.Next(8); s.SetWall(0, y, MovementDirection.WEST, IsWall.NO); } if (exitNorth) { // pick a loc with y=0, open North Debug.Log("Opening exit to North"); var x = r.Next(8); s.SetWall(x, 0, MovementDirection.NORTH, IsWall.NO); } if (exitSouth) { Debug.Log("Opening new exit to South"); // pick a loc with y=7, open South var x = r.Next(8); s.SetWall(x, 7, MovementDirection.SOUTH, IsWall.NO); } s.Tighten(); if (!s.IsOverTight()) { _constraintStates.Add(s); } }