@@ -269,20 +269,6 @@ def hint(self):
269
269
x , y = min (items , key = self ._hint_score )[0 ]
270
270
self .set_value (x , y , CLEAR_Q )
271
271
return True
272
-
273
- total = sum (probabilities .itervalues ())
274
-
275
- if total == 0 :
276
- return False
277
-
278
- choice = random .randint (1 , total )
279
-
280
- cumsum = 0
281
- for x , y in probabilities :
282
- cumsum += probabilities [x , y ]
283
- if cumsum >= choice :
284
- self .clear_space (x , y )
285
- return True
286
272
287
273
def maybe_hint (self ):
288
274
solver = self .get_solver ()
@@ -302,6 +288,12 @@ def draw_board(board, switches):
302
288
303
289
if '/p' in switches :
304
290
probabilities , total = board .get_mine_probabilities ()
291
+ # Clear terminal
292
+ print ('\x1b [2J' , end = '' )
293
+ print ('Total:' , total )
294
+ print ('Probabilities:' )
295
+ for i in probabilities :
296
+ print (i , probabilities [i ]/ total )
305
297
306
298
for x in range (board .width ):
307
299
for y in range (board .height ):
@@ -314,6 +306,11 @@ def draw_board(board, switches):
314
306
if (x , y ) in board .solver .solved_spaces :
315
307
g = board .solver .solved_spaces [x , y ] * 255
316
308
border = 1
309
+ if g == 255 :
310
+ txt = " --> (mine)"
311
+ else :
312
+ txt = " --> (clear)"
313
+ print ('Solved Spaces: ' , [x , y ], txt )
317
314
elif (x , y ) in probabilities :
318
315
g = int (probabilities [x , y ] * 255 // total )
319
316
border = 2
0 commit comments