Skip to content

Commit

Permalink
* Fix the solver; "is not []" compares for identity and is never true…
Browse files Browse the repository at this point in the history
…, should test for .length instead
  • Loading branch information
audreyt committed Dec 21, 2012
1 parent d6e33c5 commit 5bf127f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TowerLogic.js
Expand Up @@ -95,7 +95,7 @@ isDoneOrEmpty = function(towerBricks){
findSolution = function(puzzle, steps){ findSolution = function(puzzle, steps){
var possibleNextSteps, i, results$ = []; var possibleNextSteps, i, results$ = [];
window.globalsBad.callCount += 1; window.globalsBad.callCount += 1;
if (window.globalsBad.solution !== [] && steps.length > window.globalsBad.solution.length) { if (window.globalsBad.solution.length && steps.length > window.globalsBad.solution.length) {
return; return;
} }
if (window.globalsBad.penaltyMax < sum(map(function(it){ if (window.globalsBad.penaltyMax < sum(map(function(it){
Expand Down
2 changes: 1 addition & 1 deletion TowerLogic.ls
Expand Up @@ -50,7 +50,7 @@ isDoneOrEmpty = (towerBricks) ->


findSolution = (puzzle, steps) -> findSolution = (puzzle, steps) ->
window.globalsBad.callCount += 1 window.globalsBad.callCount += 1
return if window.globalsBad.solution is not [] and steps.length > window.globalsBad.solution.length return if window.globalsBad.solution.length and steps.length > window.globalsBad.solution.length
return if window.globalsBad.penaltyMax < sum map (.penalty), steps return if window.globalsBad.penaltyMax < sum map (.penalty), steps
if map (.bricks), puzzle |> all isDoneOrEmpty if map (.bricks), puzzle |> all isDoneOrEmpty
window.globalsBad.solution = steps window.globalsBad.solution = steps
Expand Down

0 comments on commit 5bf127f

Please sign in to comment.