@@ -26,6 +26,8 @@ pub struct Board {
26
26
/// There is exactly one entry in this list for every field with at least one card on it.
27
27
///
28
28
/// The `bbox` and `bitboards` fields are derived from this list.
29
+ ///
30
+ /// Note: This is not guaranteed to be sorted.
29
31
fields : Vec < ( i8 , i8 , CompactField ) > ,
30
32
/// The center coordinate for all bitboards produced by this board.
31
33
/// Using a consistent center coordinate enables binary operations like bitwise or.
@@ -298,7 +300,8 @@ impl Board {
298
300
}
299
301
300
302
pub fn to_fields_vec ( & self ) -> Vec < Field > {
301
- self . fields
303
+ let mut fields_vec: Vec < Field > = self
304
+ . fields
302
305
. iter ( )
303
306
. filter_map ( |& ( i, j, cf) | {
304
307
if cf. is_empty ( ) {
@@ -312,7 +315,9 @@ impl Board {
312
315
} )
313
316
}
314
317
} )
315
- . collect ( )
318
+ . collect ( ) ;
319
+ fields_vec. sort_by_key ( |f| ( f. i , f. j ) ) ;
320
+ fields_vec
316
321
}
317
322
318
323
// Internal helper function to compute fields where the top cards are flipped face-down.
@@ -419,7 +424,6 @@ impl Diff {
419
424
bitboards[ self . new_card . suit as usize ] . insert ( self . new_card_i , self . new_card_j ) ;
420
425
}
421
426
new_fields. push ( ( self . new_card_i , self . new_card_j , new_field) ) ;
422
- new_fields. sort_by_key ( |& ( i, j, _) | ( i, j) ) ;
423
427
}
424
428
425
429
Board {
0 commit comments