@@ -71,7 +71,7 @@ impl BeemSearch {
71
71
next_count : i8 ,
72
72
) -> i64 {
73
73
let counter = Arc :: new ( AtomicUsize :: new ( 0 ) ) ;
74
- let next_count = 4 ;
74
+ let next_count = 5 ;
75
75
76
76
//vec![1,2,3,4] -> 1234
77
77
let mut next_int = 0 ;
@@ -128,6 +128,7 @@ impl BeemSearch {
128
128
Action :: NULL ,
129
129
0 ,
130
130
false ,
131
+ -1 ,
131
132
) ;
132
133
133
134
let mut beem_width = 0 ;
@@ -323,25 +324,25 @@ impl BeemSearch {
323
324
lock_direction : i8 ,
324
325
rotate_count : i32 ,
325
326
move_flag : bool ,
327
+ count_after_softdrop : i32 ,
326
328
) {
327
329
if cfg ! ( debug_assertions) {
328
330
if move_count > 11 {
329
331
panic ! ( "ループしてない?" ) ;
330
332
}
331
333
}
334
+ if count_after_softdrop >= 3 {
335
+ return ;
336
+ }
332
337
333
- //ハードドロップ
334
- {
335
- /*
336
- if move_value == 112 || move_value == 13 {
337
- println!();
338
- } */
339
-
340
- let mut new_move_diff = Action :: HARD_DROP as i64 ;
341
- for _i in 0 ..move_count {
342
- new_move_diff *= 10 ;
343
- }
338
+ let mut new_move_diff = 1 ;
339
+
340
+ for _i in 0 ..move_count {
341
+ new_move_diff *= 10 ;
342
+ }
344
343
344
+ //ハードドロップ・ソフトドロップ
345
+ if count_after_softdrop != 0 {
345
346
let mut newmino = mino. clone ( ) ;
346
347
let mut temp = 0 ;
347
348
@@ -355,6 +356,23 @@ impl BeemSearch {
355
356
356
357
newmino. move_pos ( 0 , -temp) ;
357
358
359
+ //ソフトドロップ
360
+ if count_after_softdrop == -1 {
361
+ if temp > 0 {
362
+ Self :: search (
363
+ & mut newmino. clone ( ) ,
364
+ & field,
365
+ move_count + 1 ,
366
+ move_value + new_move_diff * Action :: SOFT_DROP as i64 ,
367
+ before_eval,
368
+ lock_direction,
369
+ rotate_count,
370
+ move_flag,
371
+ 0 ,
372
+ )
373
+ }
374
+ }
375
+
358
376
let hash =
359
377
Self :: get_hash_for_position ( newmino. mino_kind , newmino. rotation , & newmino. position ) ;
360
378
@@ -363,13 +381,13 @@ impl BeemSearch {
363
381
if let Some ( result) = searched_data. get_mut ( & hash) {
364
382
if result. move_count > move_count {
365
383
result. move_count = move_count;
366
- result. move_value = move_value + new_move_diff;
384
+ result. move_value = move_value + new_move_diff * Action :: HARD_DROP as i64 ;
367
385
}
368
386
} else {
369
387
let mut pattern = SearchedPattern :: new ( ) ;
370
388
pattern. position = newmino. position ;
371
389
pattern. move_count = move_count;
372
- pattern. move_value = move_value + new_move_diff;
390
+ pattern. move_value = move_value + new_move_diff * Action :: HARD_DROP as i64 ;
373
391
374
392
let mut field_clone = field. clone ( ) ;
375
393
@@ -410,20 +428,24 @@ impl BeemSearch {
410
428
true ,
411
429
) {
412
430
newmino. move_pos ( Vector2 :: MX1 . x , Vector2 :: MX1 . y ) ;
413
- let mut temp = Action :: MOVE_LEFT as i64 ;
414
- for _i in 0 ..move_count {
415
- temp *= 10 ;
431
+
432
+ let softdrop_value;
433
+ if count_after_softdrop == -1 {
434
+ softdrop_value = -1 ;
435
+ } else {
436
+ softdrop_value = count_after_softdrop + 1 ;
416
437
}
417
438
418
439
Self :: search (
419
440
& mut newmino,
420
441
& field,
421
442
move_count + 1 ,
422
- move_value + temp ,
443
+ move_value + new_move_diff * Action :: MOVE_LEFT as i64 ,
423
444
& before_eval,
424
445
Action :: MOVE_LEFT ,
425
446
rotate_count,
426
447
true ,
448
+ softdrop_value,
427
449
) ;
428
450
}
429
451
}
@@ -443,28 +465,31 @@ impl BeemSearch {
443
465
) {
444
466
newmino. move_pos ( Vector2 :: X1 . x , Vector2 :: X1 . y ) ;
445
467
446
- let mut temp = Action :: MOVE_RIGHT as i64 ;
447
- for _i in 0 ..move_count {
448
- temp *= 10 ;
468
+ let softdrop_value;
469
+ if count_after_softdrop == -1 {
470
+ softdrop_value = -1 ;
471
+ } else {
472
+ softdrop_value = count_after_softdrop + 1 ;
449
473
}
450
474
451
475
Self :: search (
452
476
& mut newmino,
453
477
& field,
454
478
move_count + 1 ,
455
- move_value + temp ,
479
+ move_value + new_move_diff * Action :: MOVE_RIGHT as i64 ,
456
480
& before_eval,
457
481
Action :: MOVE_RIGHT ,
458
482
rotate_count,
459
483
true ,
484
+ softdrop_value,
460
485
) ;
461
486
}
462
487
}
463
488
464
489
let mut result = Vector2 :: ZERO ;
465
490
//右回転
466
491
if !move_flag
467
- && rotate_count < 3
492
+ && rotate_count < 2
468
493
&& Environment :: try_rotate ( Rotate :: RIGHT , & field, mino, & mut result)
469
494
{
470
495
let mut newmino = mino. clone ( ) ;
@@ -482,27 +507,30 @@ impl BeemSearch {
482
507
newmino. move_pos ( result. x , result. y ) ;
483
508
Environment :: simple_rotate ( Rotate :: RIGHT , & mut newmino, 0 ) ;
484
509
485
- let mut temp = Action :: ROTATE_RIGHT as i64 ;
486
- for _i in 0 ..move_count {
487
- temp *= 10 ;
510
+ let softdrop_value;
511
+ if count_after_softdrop == -1 {
512
+ softdrop_value = -1 ;
513
+ } else {
514
+ softdrop_value = count_after_softdrop + 1 ;
488
515
}
489
516
490
517
Self :: search (
491
518
& mut newmino,
492
519
& field,
493
520
move_count + 1 ,
494
- move_value + temp ,
521
+ move_value + new_move_diff * Action :: ROTATE_RIGHT as i64 ,
495
522
& before_eval,
496
523
lock_direction,
497
524
rotate_count + 1 ,
498
525
move_flag,
526
+ softdrop_value,
499
527
) ;
500
528
}
501
529
}
502
530
503
531
//左回転
504
532
if !move_flag
505
- && rotate_count < 3
533
+ && rotate_count < 2
506
534
&& Environment :: try_rotate ( Rotate :: LEFT , & field, mino, & mut result)
507
535
{
508
536
let mut newmino = mino. clone ( ) ;
@@ -520,23 +548,28 @@ impl BeemSearch {
520
548
newmino. move_pos ( result. x , result. y ) ;
521
549
Environment :: simple_rotate ( Rotate :: LEFT , & mut newmino, 0 ) ;
522
550
523
- let mut temp = Action :: ROTATE_LEFT as i64 ;
524
- for _i in 0 ..move_count {
525
- temp *= 10 ;
551
+ let softdrop_value;
552
+ if count_after_softdrop == -1 {
553
+ softdrop_value = -1 ;
554
+ } else {
555
+ softdrop_value = count_after_softdrop + 1 ;
526
556
}
527
557
528
558
Self :: search (
529
559
& mut newmino,
530
560
& field,
531
561
move_count + 1 ,
532
- move_value + temp ,
562
+ move_value + new_move_diff * Action :: ROTATE_LEFT as i64 ,
533
563
& before_eval,
534
564
lock_direction,
535
565
rotate_count + 1 ,
536
566
move_flag,
567
+ softdrop_value,
537
568
) ;
538
569
}
539
570
}
571
+
572
+ //180回転
540
573
}
541
574
542
575
///過去の位置を記録、参照
@@ -563,8 +596,9 @@ impl BeemSearch {
563
596
result
564
597
}
565
598
599
+ #[ inline( always) ]
566
600
///位置情報を回転情報関係なく均一にする
567
- fn get_hash_for_position ( kind : i8 , rotation : i8 , position : & i64 ) -> i64 {
601
+ pub fn get_hash_for_position ( kind : i8 , rotation : i8 , position : & i64 ) -> i64 {
568
602
if rotation == Rotation :: ZERO {
569
603
return * position;
570
604
}
0 commit comments