1
1
use std:: time:: Duration ;
2
2
3
+
3
4
use crate :: algorithms:: the_algorithm:: Algorithm ;
4
5
#[ allow( unused_imports) ]
5
6
use crate :: common:: constants:: modules:: {
6
7
ALPHA_BETA , ANALYZE , NAIVE_PSQT , PAWN_STRUCTURE , SEARCH_EXTENSIONS , SKIP_BAD_MOVES ,
7
8
SQUARE_CONTROL_METRIC , TAPERED_EVERY_PESTO_PSQT , TAPERED_INCREMENTAL_PESTO_PSQT ,
8
9
TRANSPOSITION_TABLE ,
9
10
} ;
11
+ use crate :: io:: { write_result, modules_to_string} ;
10
12
11
- use self :: pitter:: logic:: Competition ;
13
+ use self :: pitter:: logic:: { Competition , CompetitionResults } ;
12
14
13
15
mod algorithms;
14
16
mod common;
15
17
mod modules;
16
18
mod pitter;
19
+ mod io;
17
20
18
21
//If we should print the moves played and results of each game.
19
22
pub ( crate ) const PRINT_GAME : bool = false ;
20
23
21
24
#[ tokio:: main]
22
25
async fn main ( ) {
23
- //ALPHA_BETA | ANALYZE | SEARCH_EXTENSIONS | SKIP_BAD_MOVES | SQUARE_CONTROL_METRIC | TRANSPOSITION_TABLE | NAIVE_PSQT | PAWN_STRUCTURE | TAPERED_EVERY_PESTO_PSQT | TAPERED_INCREMENTAL_PESTO_PSQT
24
- //Put 0 for no modules.
25
- let modules1 = ALPHA_BETA | TAPERED_EVERY_PESTO_PSQT ;
26
- let modules2 = ALPHA_BETA ;
27
- let time_per_move1 = Duration :: from_micros ( 4000 ) ;
28
- let time_per_move2 = Duration :: from_micros ( 2000 ) ;
26
+ if !TEST_SEVERAL {
27
+ //ALPHA_BETA | ANALYZE | SEARCH_EXTENSIONS | SKIP_BAD_MOVES | SQUARE_CONTROL_METRIC | TRANSPOSITION_TABLE | NAIVE_PSQT | PAWN_STRUCTURE | TAPERED_EVERY_PESTO_PSQT | TAPERED_INCREMENTAL_PESTO_PSQT
28
+ //Put 0 for no modules.
29
+ //Setup modules
30
+ let modules1 = ALPHA_BETA | TAPERED_INCREMENTAL_PESTO_PSQT ;
31
+ let modules2 = ALPHA_BETA | TAPERED_EVERY_PESTO_PSQT ;
32
+ let time_per_move1 = Duration :: from_micros ( 2000 ) ;
33
+ let time_per_move2 = Duration :: from_micros ( 2000 ) ;
34
+ let game_pairs = 500 ;
35
+
36
+ //Run competition
37
+ let result = do_competition ( modules1, modules2, time_per_move1, time_per_move2, game_pairs) . await ;
38
+
39
+ //Save results to file
40
+ let mut output: String = "Algo 1 modules: " . to_owned ( ) + & modules_to_string ( modules1) + "\n Algo 2 modules: " + & modules_to_string ( modules2) ;
41
+ let result = format ! ( "\n Competition results: {:#?}" , & result) ;
42
+ output = output + & result;
43
+ let buf = output. as_bytes ( ) ;
44
+ let _ = write_result ( buf, "./output.txt" ) ;
45
+
46
+ } else {
47
+ /*let time_per_move1 = Duration::from_micros(2000);
48
+ let time_per_move2 = Duration::from_micros(2000);
49
+
50
+ let mut modules1 = 1;
51
+ let mut modules2 = 1;
52
+
53
+ for i in 0..log2() {
54
+ for j in 0.. {
55
+
56
+ }
57
+ }*/
58
+ }
59
+
60
+ }
29
61
62
+ const TEST_SEVERAL : bool = false ;
63
+ async fn do_competition ( modules1 : u32 , modules2 : u32 , time_per_move1 : Duration , time_per_move2 : Duration , game_pairs : u32 ) -> CompetitionResults {
30
64
let competition = Competition :: new (
31
65
Algorithm :: new ( modules1, time_per_move1) ,
32
66
Algorithm :: new ( modules2, time_per_move2) ,
@@ -35,6 +69,6 @@ async fn main() {
35
69
// competition.analyze_algorithm_choices(|(game_info, _), _| {
36
70
// game_info.outcome == GameOutcome::InconclusiveTooLong
37
71
// });
38
- let results = competition. start_competition ( 1000 ) . await ;
39
- dbg ! ( results) ;
72
+ let results = competition. start_competition ( game_pairs ) . await ;
73
+ results
40
74
}
0 commit comments