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