-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUCTSearch.o.c++
3315 lines (2430 loc) · 98 KB
/
UCTSearch.o.c++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
typedef unsigned char undefined;
typedef unsigned char bool;
typedef unsigned char byte;
typedef unsigned char dwfenc;
typedef unsigned int dword;
typedef unsigned long qword;
typedef unsigned long ulong;
typedef unsigned long long ulonglong;
typedef unsigned char undefined1;
typedef unsigned int undefined4;
typedef unsigned long undefined8;
typedef unsigned short ushort;
typedef unsigned short word;
typedef ulong size_t;
typedef struct FastBoard FastBoard, *PFastBoard;
struct FastBoard { // PlaceHolder Structure
};
typedef struct UCTNode UCTNode, *PUCTNode;
struct UCTNode { // PlaceHolder Structure
};
typedef struct KoState KoState, *PKoState;
struct KoState { // PlaceHolder Structure
};
typedef struct FullBoard FullBoard, *PFullBoard;
struct FullBoard { // PlaceHolder Structure
};
typedef struct GameState GameState, *PGameState;
struct GameState { // PlaceHolder Structure
};
typedef struct Time Time, *PTime;
struct Time { // PlaceHolder Structure
};
typedef struct Playout Playout, *PPlayout;
struct Playout { // PlaceHolder Structure
};
typedef struct FastState FastState, *PFastState;
struct FastState { // PlaceHolder Structure
};
typedef struct UCTSearch UCTSearch, *PUCTSearch;
struct UCTSearch { // PlaceHolder Structure
};
typedef struct UCTWorker UCTWorker, *PUCTWorker;
struct UCTWorker { // PlaceHolder Structure
};
typedef struct allocator<int> allocator<int>, *Pallocator<int>;
struct allocator<int> { // PlaceHolder Structure
};
typedef struct _Vector_base<unsigned_long_long,std::allocator<unsigned_long_long>> _Vector_base<unsigned_long_long,std::allocator<unsigned_long_long>>, *P_Vector_base<unsigned_long_long,std::allocator<unsigned_long_long>>;
struct _Vector_base<unsigned_long_long,std::allocator<unsigned_long_long>> { // PlaceHolder Structure
};
typedef struct vector<int,std::allocator<int>> vector<int,std::allocator<int>>, *Pvector<int,std::allocator<int>>;
struct vector<int,std::allocator<int>> { // PlaceHolder Structure
};
typedef struct vector vector, *Pvector;
struct vector { // PlaceHolder Structure
};
typedef struct allocator<KoState> allocator<KoState>, *Pallocator<KoState>;
struct allocator<KoState> { // PlaceHolder Structure
};
typedef struct vector<unsigned_long_long,std::allocator<unsigned_long_long>> vector<unsigned_long_long,std::allocator<unsigned_long_long>>, *Pvector<unsigned_long_long,std::allocator<unsigned_long_long>>;
struct vector<unsigned_long_long,std::allocator<unsigned_long_long>> { // PlaceHolder Structure
};
typedef struct allocator allocator, *Pallocator;
struct allocator { // PlaceHolder Structure
};
typedef struct _Vector_base<int,std::allocator<int>> _Vector_base<int,std::allocator<int>>, *P_Vector_base<int,std::allocator<int>>;
struct _Vector_base<int,std::allocator<int>> { // PlaceHolder Structure
};
typedef struct allocator<unsigned_long_long> allocator<unsigned_long_long>, *Pallocator<unsigned_long_long>;
struct allocator<unsigned_long_long> { // PlaceHolder Structure
};
typedef struct vector<KoState,std::allocator<KoState>> vector<KoState,std::allocator<KoState>>, *Pvector<KoState,std::allocator<KoState>>;
struct vector<KoState,std::allocator<KoState>> { // PlaceHolder Structure
};
typedef struct _Vector_base<KoState,std::allocator<KoState>> _Vector_base<KoState,std::allocator<KoState>>, *P_Vector_base<KoState,std::allocator<KoState>>;
struct _Vector_base<KoState,std::allocator<KoState>> { // PlaceHolder Structure
};
typedef struct _Vector_impl _Vector_impl, *P_Vector_impl;
struct _Vector_impl { // PlaceHolder Structure
};
typedef struct _Vector_impl_data _Vector_impl_data, *P_Vector_impl_data;
struct _Vector_impl_data { // PlaceHolder Structure
};
typedef struct basic_string basic_string, *Pbasic_string;
struct basic_string { // PlaceHolder Structure
};
typedef struct basic_string<char,std::char_traits<char>,std::allocator<char>> basic_string<char,std::char_traits<char>,std::allocator<char>>, *Pbasic_string<char,std::char_traits<char>,std::allocator<char>>;
struct basic_string<char,std::char_traits<char>,std::allocator<char>> { // PlaceHolder Structure
};
typedef struct new_allocator<KoState> new_allocator<KoState>, *Pnew_allocator<KoState>;
struct new_allocator<KoState> { // PlaceHolder Structure
};
typedef struct new_allocator new_allocator, *Pnew_allocator;
struct new_allocator { // PlaceHolder Structure
};
typedef struct __normal_iterator<KoState_const*,std::vector<KoState,std::allocator<KoState>>> __normal_iterator<KoState_const*,std::vector<KoState,std::allocator<KoState>>>, *P__normal_iterator<KoState_const*,std::vector<KoState,std::allocator<KoState>>>;
struct __normal_iterator<KoState_const*,std::vector<KoState,std::allocator<KoState>>> { // PlaceHolder Structure
};
typedef dword __normal_iterator;
typedef struct new_allocator<unsigned_long_long> new_allocator<unsigned_long_long>, *Pnew_allocator<unsigned_long_long>;
struct new_allocator<unsigned_long_long> { // PlaceHolder Structure
};
typedef struct new_allocator<int> new_allocator<int>, *Pnew_allocator<int>;
struct new_allocator<int> { // PlaceHolder Structure
};
typedef struct __normal_iterator<unsigned_long_long_const*,std::vector<unsigned_long_long,std::allocator<unsigned_long_long>>> __normal_iterator<unsigned_long_long_const*,std::vector<unsigned_long_long,std::allocator<unsigned_long_long>>>, *P__normal_iterator<unsigned_long_long_const*,std::vector<unsigned_long_long,std::allocator<unsigned_long_long>>>;
struct __normal_iterator<unsigned_long_long_const*,std::vector<unsigned_long_long,std::allocator<unsigned_long_long>>> { // PlaceHolder Class Structure
};
typedef struct __normal_iterator<int_const*,std::vector<int,std::allocator<int>>> __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>, *P__normal_iterator<int_const*,std::vector<int,std::allocator<int>>>;
struct __normal_iterator<int_const*,std::vector<int,std::allocator<int>>> { // PlaceHolder Class Structure
};
typedef struct Elf64_Rela Elf64_Rela, *PElf64_Rela;
struct Elf64_Rela {
qword r_offset; // location to apply the relocation action
qword r_info; // the symbol table index and the type of relocation
qword r_addend; // a constant addend used to compute the relocatable field value
};
typedef struct Elf64_Shdr Elf64_Shdr, *PElf64_Shdr;
typedef enum Elf_SectionHeaderType {
SHT_NULL=0,
SHT_PROGBITS=1,
SHT_SYMTAB=2,
SHT_STRTAB=3,
SHT_RELA=4,
SHT_HASH=5,
SHT_DYNAMIC=6,
SHT_NOTE=7,
SHT_NOBITS=8,
SHT_REL=9,
SHT_SHLIB=10,
SHT_DYNSYM=11,
SHT_INIT_ARRAY=14,
SHT_FINI_ARRAY=15,
SHT_PREINIT_ARRAY=16,
SHT_GROUP=17,
SHT_SYMTAB_SHNDX=18,
SHT_ANDROID_REL=1610612737,
SHT_ANDROID_RELA=1610612738,
SHT_GNU_ATTRIBUTES=1879048181,
SHT_GNU_HASH=1879048182,
SHT_GNU_LIBLIST=1879048183,
SHT_CHECKSUM=1879048184,
SHT_SUNW_move=1879048186,
SHT_SUNW_COMDAT=1879048187,
SHT_SUNW_syminfo=1879048188,
SHT_GNU_verdef=1879048189,
SHT_GNU_verneed=1879048190,
SHT_GNU_versym=1879048191
} Elf_SectionHeaderType;
struct Elf64_Shdr {
dword sh_name;
enum Elf_SectionHeaderType sh_type;
qword sh_flags;
qword sh_addr;
qword sh_offset;
qword sh_size;
dword sh_link;
dword sh_info;
qword sh_addralign;
qword sh_entsize;
};
typedef struct Elf64_Ehdr Elf64_Ehdr, *PElf64_Ehdr;
struct Elf64_Ehdr {
byte e_ident_magic_num;
char e_ident_magic_str[3];
byte e_ident_class;
byte e_ident_data;
byte e_ident_version;
byte e_ident_osabi;
byte e_ident_abiversion;
byte e_ident_pad[7];
word e_type;
word e_machine;
dword e_version;
qword e_entry;
qword e_phoff;
qword e_shoff;
dword e_flags;
word e_ehsize;
word e_phentsize;
word e_phnum;
word e_shentsize;
word e_shnum;
word e_shstrndx;
};
typedef struct Elf64_Sym Elf64_Sym, *PElf64_Sym;
struct Elf64_Sym {
dword st_name;
byte st_info;
byte st_other;
word st_shndx;
qword st_value;
qword st_size;
};
// UCTSearch::UCTSearch(GameState&)
void __thiscall UCTSearch::UCTSearch(UCTSearch *this,GameState *param_1)
{
int iVar1;
*(GameState **)this = param_1;
iVar1 = FastState::get_to_move();
UCTNode::UCTNode((UCTNode *)(this + 8),iVar1,-1);
*(undefined4 *)(this + 0x40) = 0;
*(undefined4 *)(this + 0x44) = 500000000;
*(undefined4 *)(this + 0x48) = 0;
this[0x4d] = (UCTSearch)0x0;
*(undefined8 *)(this + 0x50) = 0;
this[0x58] = (UCTSearch)0x0;
return;
}
// UCTSearch::set_runflag(bool*)
void __thiscall UCTSearch::set_runflag(UCTSearch *this,bool *param_1)
{
*(bool **)(this + 0x50) = param_1;
this[0x4d] = (UCTSearch)0x1;
return;
}
// WARNING: Could not reconcile some variable overlaps
// UCTSearch::play_simulation(KoState&, UCTNode*)
undefined8 * UCTSearch::play_simulation(KoState *param_1,UCTNode *param_2)
{
bool bVar1;
undefined8 *puVar2;
char cVar3;
int iVar4;
int iVar5;
ulonglong uVar6;
FastState *in_RCX;
undefined8 in_RDX;
float extraout_XMM0_Da;
undefined8 local_e8;
undefined8 local_e0;
undefined8 local_d8;
undefined8 local_d0;
undefined8 local_c8;
undefined8 local_c0;
undefined8 local_b8;
undefined8 local_b0;
undefined8 local_a8;
undefined8 local_a0;
undefined8 local_98;
undefined8 local_90;
undefined8 local_88;
undefined8 local_80;
undefined8 local_78;
FastState *local_68;
undefined8 local_60;
UCTNode *local_58;
undefined8 *local_50;
int local_3c;
long local_38;
char local_29;
UCTNode *local_28;
undefined4 local_1c;
local_68 = in_RCX;
local_60 = in_RDX;
local_58 = param_2;
local_50 = (undefined8 *)param_1;
local_1c = FastState::get_to_move();
local_28 = (UCTNode *)FullBoard::get_hash();
Playout::Playout((Playout *)local_50);
uVar6 = TTable::get_TT();
TTable::sync(uVar6,local_28);
local_29 = UCTNode::has_children();
if (local_29 == '\0') {
iVar4 = UCTNode::get_visits();
iVar5 = UCTNode::do_extend();
if (iVar4 <= iVar5) {
bVar1 = true;
goto LAB_0010014d;
}
}
bVar1 = false;
LAB_0010014d:
if (bVar1) {
Playout::run((FastState *)local_50,SUB81(local_60,0));
}
else {
if ((local_29 == '\0') && (*(int *)(local_58 + 0x40) < 5000000)) {
iVar4 = UCTNode::create_children(local_68,SUB81(local_60,0));
*(int *)(local_58 + 0x40) = iVar4 + *(int *)(local_58 + 0x40);
}
cVar3 = UCTNode::has_children();
if (cVar3 == '\x01') {
local_38 = UCTNode::uct_select_child((int)local_68);
if (local_38 == 0) {
Playout::run((FastState *)local_50,SUB81(local_60,0));
}
else {
local_3c = UCTNode::get_move();
if (local_3c == -1) {
KoState::play_pass();
puVar2 = local_50;
play_simulation((KoState *)&local_e8,local_58);
*puVar2 = local_e8;
puVar2[1] = local_e0;
puVar2[2] = local_d8;
puVar2[3] = local_d0;
puVar2[4] = local_c8;
puVar2[5] = local_c0;
puVar2[6] = local_b8;
puVar2[7] = local_b0;
puVar2[8] = local_a8;
puVar2[9] = local_a0;
puVar2[10] = local_98;
puVar2[0xb] = local_90;
puVar2[0xc] = local_88;
puVar2[0xd] = local_80;
puVar2[0xe] = local_78;
}
else {
KoState::play_move((int)local_60);
cVar3 = KoState::superko();
puVar2 = local_50;
if (cVar3 == '\x01') {
UCTNode::invalidate();
Playout::run((FastState *)local_50,(bool)(undefined)local_60);
}
else {
play_simulation((KoState *)&local_e8,local_58);
*puVar2 = local_e8;
puVar2[1] = local_e0;
puVar2[2] = local_d8;
puVar2[3] = local_d0;
puVar2[4] = local_c8;
puVar2[5] = local_c0;
puVar2[6] = local_b8;
puVar2[7] = local_b0;
puVar2[8] = local_a8;
puVar2[9] = local_a0;
puVar2[10] = local_98;
puVar2[0xb] = local_90;
puVar2[0xc] = local_88;
puVar2[0xd] = local_80;
puVar2[0xe] = local_78;
}
}
}
UCTNode::updateRAVE((Playout *)local_68,(int)local_50);
}
else if (*(int *)(local_58 + 0x40) < 5000000) {
FastState::percentual_area_score();
Playout::set_final_score(extraout_XMM0_Da);
}
else {
Playout::run((FastState *)local_50,SUB81(local_60,0));
}
}
UCTNode::update((Playout *)local_68,(int)local_50);
uVar6 = TTable::get_TT();
TTable::update(uVar6,local_28);
return local_50;
}
// UCTSearch::dump_stats(GameState&, UCTNode&)
void __thiscall UCTSearch::dump_stats(UCTSearch *this,GameState *param_1,UCTNode *param_2)
{
char cVar1;
int iVar2;
uint uVar3;
int iVar4;
uint uVar5;
undefined8 uVar6;
undefined8 uVar7;
char *pcVar8;
basic_string_char_std__char_traits_char__std__allocator_char__ local_4358 [32];
GameState local_4338 [8512];
GameState local_21f8 [8512];
basic_string_char_std__char_traits_char__std__allocator_char__ local_b8 [32];
GameState local_98 [32];
GameState local_78 [40];
long local_50;
float local_48;
undefined4 local_44;
undefined4 local_40;
undefined4 local_3c;
long local_38;
int local_2c;
local_3c = FastState::get_to_move();
local_40 = 0xffffffff;
local_44 = 0;
local_48 = 0.0;
cVar1 = UCTNode::has_children();
if (cVar1 == '\x01') {
UCTNode::sort_children((int)this + 8);
local_50 = UCTNode::get_first_child();
cVar1 = UCTNode::first_visit();
if (cVar1 == '\0') {
iVar2 = UCTNode::get_winrate((int)local_50);
local_48 = (float)iVar2;
local_44 = UCTNode::get_visits();
local_40 = UCTNode::get_move();
local_2c = 0;
local_38 = local_50;
while ((iVar2 = (int)register0x00000020, local_38 != 0 &&
(local_2c = local_2c + 1, local_2c < 7))) {
UCTNode::get_move();
FastState::move_to_text_abi_cxx11_(iVar2 + -0x4358);
uVar7 = std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str
();
uVar5 = UCTNode::get_ravevisits();
iVar4 = UCTNode::get_visits();
if (0 < iVar4) {
UCTNode::get_raverate();
}
iVar4 = UCTNode::get_visits();
if (iVar4 < 1) {
pcVar8 = (char *)0x0;
}
else {
iVar4 = UCTNode::get_winrate((int)local_38);
pcVar8 = (char *)(double)((float)iVar4 / 10.0);
}
uVar3 = UCTNode::get_visits();
uVar6 = std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str
();
Utils::myprintf(pcVar8,"%4s -> %7d (U: %4.1f%%) (R: %4.1f%%: %7d) PV: %s ",uVar6,
(ulong)uVar3,(ulong)uVar5,uVar7);
GameState::GameState(local_4338,param_1);
UCTNode::get_move();
GameState::play_move(iVar2 + -0x4338);
get_pv_abi_cxx11_(local_98,(UCTNode *)this);
pcVar8 = (char *)std::__cxx11::
basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str();
Utils::myprintf(pcVar8);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
((basic_string_char_std__char_traits_char__std__allocator_char__ *)local_98);
Utils::myprintf("\n");
local_38 = UCTNode::get_sibling();
_ZN9GameStateD1Ev(local_4338);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
(local_4358);
}
UCTNode::get_move();
FastState::move_to_text_abi_cxx11_(iVar2 + -0xb8);
uVar7 = std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str();
iVar2 = UCTNode::get_winrate((int)param_2);
iVar4 = UCTNode::get_visits();
if (iVar4 < 1) {
pcVar8 = (char *)0x0;
}
else {
iVar4 = UCTNode::get_winrate((int)local_50);
pcVar8 = (char *)(double)((float)iVar4 / 10.0);
}
uVar5 = UCTNode::get_visits();
Utils::myprintf(pcVar8,(double)((float)iVar2 / 10.0),
"====================================\n%d visits, score %4.1f%% (from %4.1f%%) PV: "
,(ulong)uVar5,uVar7);
GameState::GameState(local_21f8,param_1);
get_pv_abi_cxx11_(local_78,(UCTNode *)this);
pcVar8 = (char *)std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>
::c_str();
Utils::myprintf(pcVar8);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
((basic_string_char_std__char_traits_char__std__allocator_char__ *)local_78);
Utils::myprintf("\n");
_ZN9GameStateD1Ev(local_21f8);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
(local_b8);
}
}
return;
}
// UCTSearch::get_best_move(int)
int __thiscall UCTSearch::get_best_move(UCTSearch *this,int param_1)
{
char cVar1;
int iVar2;
int iVar3;
int iVar4;
long lVar5;
float fVar6;
float extraout_XMM0_Da;
float local_20;
int local_1c;
iVar3 = *(int *)(*(long *)this + 0x6e8);
UCTNode::sort_children((int)this + 8);
UCTNode::get_first_child();
local_1c = UCTNode::get_move();
lVar5 = UCTNode::get_first_child();
if (lVar5 != 0) {
UCTNode::get_first_child();
cVar1 = UCTNode::first_visit();
if (cVar1 != '\0') {
return local_1c;
}
}
iVar2 = UCTNode::get_first_child();
iVar2 = UCTNode::get_winrate(iVar2);
local_20 = (float)iVar2 / 1000.0;
UCTNode::get_first_child();
iVar2 = UCTNode::get_visits();
*(float *)(this + 0x48) = local_20;
if ((param_1 & 1U) == 0) {
iVar4 = FastState::get_last_move();
if ((iVar4 == -1) && (lVar5 = UCTNode::get_pass_child(), lVar5 != 0)) {
UCTNode::get_pass_child();
iVar4 = UCTNode::get_visits();
if (100 < iVar4) {
iVar4 = UCTNode::get_pass_child();
iVar4 = UCTNode::get_winrate(iVar4);
fVar6 = (float)iVar4 / 1000.0;
if ((0.9 < fVar6) && (local_20 - fVar6 < 0.05)) {
Utils::myprintf((char *)(double)(fVar6 * 100.0),
"Preferring to pass since it\'s %5.2f%% compared to %5.2f%%.\n");
local_1c = -1;
}
}
}
if (local_1c == -1) {
FastState::final_score();
if (((0.0 < extraout_XMM0_Da) && (iVar3 == 1)) || ((extraout_XMM0_Da < 0.0 && (iVar3 == 0))))
{
Utils::myprintf("Passing loses :-(\n");
lVar5 = UCTNode::get_nopass_child();
if (lVar5 == 0) {
Utils::myprintf("No alternative to passing.\n");
}
else {
Utils::myprintf("Avoiding pass because it loses.\n");
local_1c = UCTNode::get_move();
cVar1 = UCTNode::first_visit();
if (cVar1 == '\0') {
iVar3 = UCTNode::get_winrate((int)lVar5);
local_20 = (float)iVar3 / 1000.0;
}
else {
local_20 = 1.0;
}
}
}
else {
Utils::myprintf((char *)0x0,0,"Passing wins :-)\n");
}
}
}
else if (local_1c == -1) {
lVar5 = UCTNode::get_nopass_child();
if (lVar5 == 0) {
Utils::myprintf("Pass is the only acceptable move.\n");
}
else {
Utils::myprintf("Preferring not to pass.\n");
local_1c = UCTNode::get_move();
cVar1 = UCTNode::first_visit();
if (cVar1 == '\0') {
iVar3 = UCTNode::get_winrate((int)lVar5);
local_20 = (float)iVar3 / 1000.0;
}
else {
local_20 = 1.0;
}
}
}
if ((local_1c != -1) && ((param_1 & 2U) == 0)) {
iVar3 = FastBoard::get_boardsize();
iVar4 = FastBoard::get_boardsize();
if ((local_20 < 0.15) &&
((0x5a < iVar2 && ((iVar4 * iVar3) / 3 < *(int *)(*(long *)this + 0x1f98))))) {
Utils::myprintf("Score looks bad. Resigning.\n");
local_1c = -2;
}
}
return local_1c;
}
// UCTSearch::get_pv[abi:cxx11](GameState&, UCTNode&)
GameState * UCTSearch::get_pv_abi_cxx11_(GameState *param_1,UCTNode *param_2)
{
char cVar1;
int iVar2;
int in_ECX;
int in_EDX;
GameState local_88 [32];
basic_string local_68 [32];
basic_string_char_std__char_traits_char__std__allocator_char__ local_48 [36];
undefined4 local_24;
undefined8 local_20;
cVar1 = UCTNode::has_children();
if (cVar1 == '\x01') {
FastState::get_to_move();
UCTNode::sort_children(in_ECX);
local_20 = UCTNode::get_first_child();
iVar2 = UCTNode::get_visits();
if (iVar2 < 0x10) {
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string();
}
else {
local_24 = UCTNode::get_move();
FastState::move_to_text_abi_cxx11_((int)register0x00000020 + -0x48);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string
(local_68);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::append
((char *)local_68);
GameState::play_move(in_EDX);
get_pv_abi_cxx11_(local_88,param_2);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::append(local_68)
;
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string
((basic_string *)param_1);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
((basic_string_char_std__char_traits_char__std__allocator_char__ *)local_88);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
((basic_string_char_std__char_traits_char__std__allocator_char__ *)local_68);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
(local_48);
}
}
else {
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string();
}
return param_1;
}
// UCTSearch::dump_analysis()
void __thiscall UCTSearch::dump_analysis(UCTSearch *this)
{
int iVar1;
uint uVar2;
float *pfVar3;
undefined8 uVar4;
char *pcVar5;
float local_218c;
GameState local_2188 [32];
GameState local_2168 [1768];
undefined4 local_1a80;
float local_24;
float local_20;
undefined4 local_1c;
GameState::GameState(local_2168,*(GameState **)this);
local_1c = local_1a80;
get_pv_abi_cxx11_(local_2188,(UCTNode *)this);
iVar1 = UCTNode::get_winrate((int)this + 8);
local_218c = (float)iVar1 / 10.0;
local_24 = 0.0;
pfVar3 = std::max_float_(&local_24,&local_218c);
local_218c = *pfVar3;
local_20 = 100.0;
pfVar3 = std::min_float_(&local_20,&local_218c);
local_218c = *pfVar3;
uVar4 = std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str();
pcVar5 = (char *)(double)local_218c;
uVar2 = UCTNode::get_visits();
Utils::myprintf(pcVar5,"Nodes: %d, Win: %4.1f%%, PV: %s\n",(ulong)uVar2,uVar4);
std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::_basic_string
((basic_string_char_std__char_traits_char__std__allocator_char__ *)local_2188);
_ZN9GameStateD1Ev(local_2168);
return;
}
// UCTSearch::is_running()
UCTSearch __thiscall UCTSearch::is_running(UCTSearch *this)
{
return this[0x4c];
}
// UCTWorker::TEMPNAMEPLACEHOLDERVALUE()
void __thiscall UCTWorker::operator__(UCTWorker *this)
{
char cVar1;
KoState local_2198 [8448];
KoState local_98 [136];
do {
KoState::KoState(local_2198,*(KoState **)this);
UCTSearch::play_simulation(local_98,*(UCTNode **)(this + 0x10));
_ZN7KoStateD1Ev(local_2198);
cVar1 = UCTSearch::is_running(*(UCTSearch **)(this + 0x10));
} while (cVar1 != '\0');
return;
}
// UCTSearch::get_score()
undefined4 __thiscall UCTSearch::get_score(UCTSearch *this)
{
return *(undefined4 *)(this + 0x48);
}
// UCTSearch::think(int, int)
undefined4 __thiscall UCTSearch::think(UCTSearch *this,int param_1,int param_2)
{
uint uVar1;
char cVar2;
ushort uVar3;
int iVar4;
uint uVar5;
undefined4 uVar6;
long lVar7;
KoState local_21b8 [8444];
Time local_bc [4];
KoState local_b8 [124];
undefined4 local_3c;
undefined4 local_30;
undefined4 local_2c;
int local_28;
char local_21;
int local_20;
int local_1c;
*(int *)(*(long *)this + 0x6e8) = param_1;
Time::Time(local_bc);
local_2c = 0;
if (this[0x58] == (UCTSearch)0x1) {
local_30 = 500000000;
}
else {
iVar4 = GameState::get_timecontrol();
local_30 = TimeControl::max_time_for_move(iVar4);
iVar4 = FastState::get_handicap();
if (iVar4 == 0) {
lVar7 = FullBoard::get_ko_hash();
if (lVar7 == -0x3aab42ef967136cd) {
return 0x3c;
}
lVar7 = FullBoard::get_ko_hash();
if (lVar7 == 0x16d49b38172bae63) {
uVar3 = Random::get_Rng();
iVar4 = Random::randint(uVar3);
if (iVar4 == 0) {
return 0x52;
}
return 0x51;
}
lVar7 = FullBoard::get_ko_hash();
if (lVar7 == -0x6b3241ddd2b180e1) {
uVar3 = Random::get_Rng();
iVar4 = Random::randint(uVar3);
if (iVar4 == 0) {
return 0x160;
}
if (iVar4 == 1) {
return 0x175;
}
return 0x176;
}
}
}
local_1c = 0;
local_20 = 0;
iVar4 = FastBoard::get_boardsize();
if (iVar4 == 9) {
local_1c = 10000;
local_20 = 2000;
}
else {
local_1c = 4000;
local_20 = 1000;
}
GameState::start_clock((int)*(undefined8 *)this);
MCOwnerTable::clear();
Playout::mc_owner(*(FastState **)this,0x40);
iVar4 = UCTNode::create_children((FastState *)(this + 8),SUB81(*(undefined8 *)this,0));
*(int *)(this + 0x40) = iVar4 + *(int *)(this + 0x40);
UCTNode::kill_superkos((KoState *)(this + 8));
this[0x4c] = (UCTSearch)0x1;
local_3c = 1;
local_21 = '\x01';
local_28 = 0;
do {
KoState::KoState(local_21b8,*(KoState **)this);
play_simulation(local_b8,(UCTNode *)this);
if (this[0x58] == (UCTSearch)0x1) {
if (local_28 % local_20 == 0) {
dump_analysis(this);
}
if ((this[0x4d] == (UCTSearch)0x1) && (**(char **)(this + 0x50) == '\0')) {
local_21 = '\0';
}
else {
local_21 = '\x01';
}
}
else {
if (local_28 % local_20 == 0) {
dump_analysis(this);
}
iVar4 = UCTNode::get_visits();
if ((iVar4 < *(int *)(this + 0x44)) &&
((this[0x4d] != (UCTSearch)0x1 || (**(char **)(this + 0x50) != '\0')))) {
local_21 = '\x01';
}
else {
local_21 = '\0';
}
}
if (local_1c < local_28) {
local_21 = '\0';
}
local_28 = local_28 + 1;
_ZN7KoStateD1Ev(local_21b8);
} while (local_21 != '\0');
this[0x4c] = (UCTSearch)0x0;
cVar2 = UCTNode::has_children();
if (cVar2 == '\x01') {
GameState::stop_clock((int)*(undefined8 *)this);
Utils::myprintf("\n");
dump_stats(this,*(GameState **)this,(UCTNode *)(this + 8));
uVar1 = *(uint *)(this + 0x40);
uVar5 = UCTNode::get_visits();
Utils::myprintf("\n%d visits, %d nodes\n\n",(ulong)uVar5,(ulong)uVar1);
uVar6 = get_best_move(this,param_2);
}
else {
uVar6 = 0xffffffff;
}
return uVar6;
}
// UCTSearch::ponder()
void __thiscall UCTSearch::ponder(UCTSearch *this)
{
uint uVar1;
bool bVar2;
char cVar3;
uint uVar4;
KoState local_2198 [8448];
KoState local_98 [124];
undefined4 local_1c;
MCOwnerTable::clear();
Playout::mc_owner(*(FastState **)this,0x40);
this[0x4c] = (UCTSearch)0x1;
local_1c = SMP::get_num_cpus();
do {
KoState::KoState(local_2198,*(KoState **)this);
play_simulation(local_98,(UCTNode *)this);
_ZN7KoStateD1Ev(local_2198);
cVar3 = Utils::input_pending();
if ((cVar3 == '\x01') || ((this[0x4d] == (UCTSearch)0x1 && (**(char **)(this + 0x50) == '\0'))))
{
bVar2 = false;
}
else {
bVar2 = true;
}
} while (bVar2);
this[0x4c] = (UCTSearch)0x0;
Utils::myprintf("\n");
dump_stats(this,*(GameState **)this,(UCTNode *)(this + 8));
uVar1 = *(uint *)(this + 0x40);
uVar4 = UCTNode::get_visits();
Utils::myprintf("\n%d visits, %d nodes\n\n",(ulong)uVar4,(ulong)uVar1);
return;
}
// UCTSearch::set_visit_limit(int)
void __thiscall UCTSearch::set_visit_limit(UCTSearch *this,int param_1)
{
if (param_1 == 0) {
*(undefined4 *)(this + 0x44) = 500000000;
}
else {
*(int *)(this + 0x44) = param_1;
}
return;
}
// UCTSearch::set_analyzing(bool)
void __thiscall UCTSearch::set_analyzing(UCTSearch *this,bool param_1)