瀏覽代碼

Revert "super long run "monte carlo" (it's not really mc)"

This reverts commit d0ce2b5c0058fdd7a1db54e6f310062ea0cc01a5.
Guillaume Koenig 7 年之前
父節點
當前提交
92b50ddcf5
共有 1 個文件被更改,包括 4 次插入21 次删除
  1. 4 21
      main.go

+ 4 - 21
main.go

@@ -136,7 +136,6 @@ func max(a, b int) int {
136
 }
136
 }
137
 
137
 
138
 var bestTotalScore int
138
 var bestTotalScore int
139
-var movingFromDepth int
140
 
139
 
141
 func save() {
140
 func save() {
142
 	if bestTotalScore < 10900000 {
141
 	if bestTotalScore < 10900000 {
@@ -217,8 +216,6 @@ func (c *Car) pickRandomRide() *Ride {
217
 	return nil
216
 	return nil
218
 }
217
 }
219
 
218
 
220
-var shots int
221
-
222
 // invariant : when entering and leaving function,
219
 // invariant : when entering and leaving function,
223
 // Sched has the "same" heap. Same means successive
220
 // Sched has the "same" heap. Same means successive
224
 // popped values will be the same (but the internal
221
 // popped values will be the same (but the internal
@@ -232,27 +229,13 @@ func Choose(cumulativeScore int, depth int, fromDepth int) (int, bool) {
232
 	c := Sched.Pop()
229
 	c := Sched.Pop()
233
 	if c == nil {
230
 	if c == nil {
234
 		// At this point we have a complete configuration
231
 		// At this point we have a complete configuration
232
+		fmt.Printf("score obtained: %d depth: %d\n", cumulativeScore, depth)
235
 		if cumulativeScore >= bestTotalScore {
233
 		if cumulativeScore >= bestTotalScore {
236
-			if cumulativeScore != bestTotalScore {
237
-				save()
238
-				bestTotalScore = cumulativeScore
239
-				// movingFromDepth = fromDepth
240
-				shots = 0
241
-				movingFromDepth += 1
242
-			}
243
-			shots += 1
244
-			if shots-1 == 1 {
245
-				shots = 0
246
-				movingFromDepth += 1
247
-			}
234
+			bestTotalScore = cumulativeScore
248
 			// Go back to random depth and make a new change
235
 			// Go back to random depth and make a new change
249
-			// rnd := rand.Intn(depth-movingFromDepth-1) + 1 + movingFromDepth
250
-			rnd := movingFromDepth
251
-			fmt.Printf("best score! %d depth: %d fromDepth: %d movingFromDepth: %d rnd: %d\n", cumulativeScore, depth, fromDepth, movingFromDepth, rnd)
252
-			return rnd, false
236
+			return rand.Intn(depth), false
253
 		} else {
237
 		} else {
254
 			// Go back to fix change that lowered our score
238
 			// Go back to fix change that lowered our score
255
-			fmt.Printf("lesser score: %d depth: %d fromDepth: %d movingFromDepth: %d\n", cumulativeScore, depth, fromDepth, movingFromDepth)
256
 			return fromDepth, true
239
 			return fromDepth, true
257
 		}
240
 		}
258
 	}
241
 	}
@@ -285,7 +268,7 @@ func Choose(cumulativeScore int, depth int, fromDepth int) (int, bool) {
285
 }
268
 }
286
 
269
 
287
 func solve() {
270
 func solve() {
288
-	rand.Seed(100000)
271
+	rand.Seed(1)
289
 
272
 
290
 	sort.Sort(ByEndtime(Rides))
273
 	sort.Sort(ByEndtime(Rides))
291
 
274