comparison src/lifter.tp @ 62:ff2b38518a58

Updated heuristic
author Mike Pavone <pavone@retrodev.com>
date Mon, 16 Jul 2012 04:03:03 -0700
parents f851895ea67a
children ff8d7b4499f5
comparison
equal deleted inserted replaced
61:f851895ea67a 62:ff2b38518a58
110 me <-curstate getRobot 110 me <-curstate getRobot
111 candidates <- curstate validMoves: (me x) (me y) 111 candidates <- curstate validMoves: (me x) (me y)
112 foreach: candidates :idx move { 112 foreach: candidates :idx move {
113 curfield <- curstate clone 113 curfield <- curstate clone
114 curfield advance: (move cmd) 114 curfield advance: (move cmd)
115 if: (not: (visitedStates contains?: curfield)) { 115 if: (curfield ended) {
116 visitedStates add: curfield 116 if: (curfield score) > (curbest score) {
117 if: (curfield ended) { 117 curbest <- curfield
118 if: (curfield score) > (curbest score) { 118 }
119 curbest <- curfield 119 } else: {
120 } 120 //check theoretical max score for current map state
121 } else: { 121 //discard paths that can never be better than our current best
122 //check theoretical max score for current map state 122 if: (curfield maxScore) > (curbest score) {
123 //discard paths that can never be better than our current best 123 if: (not: (visitedStates contains?: curfield)) {
124 if: (curfield maxScore) > (curbest score) { 124 visitedStates add: curfield
125 nextstates append: curfield 125 nextstates append: curfield
126 } 126 }
127 } 127 }
128 } 128 }
129 } 129 }