Ejemplo n.º 1
0
        public void DoubleRook_EndGame(int searchDepth, LogicSettings settings)
        {
            // 8   K
            // 7   R
            // 6
            // 5   R
            // 4
            // 3
            // 2    K
            // 1
            //  ABCDEFGH
            var board  = new Board();
            var pieces = new List <PieceBase>
            {
                new Rook(false, "d5"),
                new Rook(false, "d7"),
                new King(true, "e2"),
                new King(false, "d8")
            };

            board.AddNew(pieces);

            var player = new Logic(false, board);

            player.Settings = settings;

            var playerMove  = player.CreateMoveWithDepth(searchDepth);
            var diagnostics = playerMove.Diagnostics;

            Logger.LogMessage($"// Test: {nameof(DoubleRook_EndGame)}. Move: {playerMove.Move.StartPosition} to {playerMove.Move.EndPosition}. Depth {searchDepth}");
            Logger.LogMessage($"// {diagnostics.ToString()}");
        }
Ejemplo n.º 2
0
        public void UpdateTags(LogicSettings ls)
        {
            var tags = new List <string>();

            if (ls.PokemonsToEvolve.Contains(PokemonId))
            {
                tags.Add("ev");
            }
            if (ls.PokemonToUseMasterball.Contains(PokemonId))
            {
                tags.Add("mb");
            }
            if (ls.PokemonsNotToCatch.Contains(PokemonId))
            {
                tags.Add("nc");
            }
            if (ls.PokemonsNotToTransfer.Contains(PokemonId))
            {
                tags.Add("nt");
            }
            if (ls.PokemonsTransferFilter.ContainsKey(PokemonId))
            {
                tags.Add("tf");
            }
            Tags = tags.Count > 0 ? tags.Aggregate((x, v) => x + ", " + v) : "";
        }
Ejemplo n.º 3
0
        public BotWindowData(string name, GlobalSettings gs, StateMachine sm, Statistics st, StatisticsAggregator sa, WpfEventListener wel, ClientSettings cs, LogicSettings l)
        {
            ProfileName    = name;
            GlobalSettings = gs;
            Machine        = sm;
            Stats          = st;
            Aggregator     = sa;
            Listener       = wel;
            Settings       = cs;
            Logic          = l;
            Lat            = gs.LocationSettings.DefaultLatitude;
            Lng            = gs.LocationSettings.DefaultLongitude;

            Ts     = new TimeSpan();
            _timer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 1)
            };
            _timer.Tick += delegate
            {
                Ts += new TimeSpan(0, 0, 1);
                _realWorkSec++;
            };
            _cts        = new CancellationTokenSource();
            _pauseCts   = new CancellationTokenSource();
            PlayerRoute = new GMapRoute(_routePoints);
            PathRoute   = new GMapRoute(new List <PointLatLng>());

            GlobalPlayerMarker = new GMapMarker(new PointLatLng(Lat, Lng))
            {
                Shape  = Properties.Resources.trainer.ToImage("Player - " + ProfileName),
                Offset = new Point(-14, -40),
                ZIndex = 15
            };
        }
Ejemplo n.º 4
0
 public MainWindow()
 {
     _controller = new MainLogicController(LogicSettings.ConstructFromSettings(Settings), Dispatcher);
     DataContext = _controller;
     InitializeComponent();
     GameSelector.ItemsSource   = GamesHelper.GetListOfSupportedGames();
     GameSelector.SelectedValue = Settings.SelectedGameName;
 }
Ejemplo n.º 5
0
        public void RunAll_IterativeDeepening_NoTranspositions()
        {
            var settings = new LogicSettings()
            {
                UseParallelComputation = false,
                UseTranspositionTables = false,
                UseIterativeDeepening  = true,
                UseFullDiagnostics     = true
            };

            RunAll(5, settings, true);

            // 17-18 sec.
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1447494. Check evaluations: 968. Alpha cutoffs: 103126. Beta cutoffs: 76564. Time elapsed: 6762 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 3118588. Check evaluations: 1471. Alpha cutoffs: 130994. Beta cutoffs: 180534. Time elapsed: 10460 ms. Available moves found: 40.

            // 3.6 sec. 24.1.2021 - Keep tabs on alpha&beta values on the minimax launching function
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 231069. Check evaluations: 968. Alpha cutoffs: 62084. Beta cutoffs: 5624. Time elapsed: 1530 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 423044. Check evaluations: 1471. Alpha cutoffs: 11542. Beta cutoffs: 106093. Time elapsed: 2018 ms. Available moves found: 40.

            // 5.4 sec. 19.2. add timer and midresult check
            // Test: RuyLopez_Black. Move: c6 to d4. Depth 5
            // Board evaluations: 448738. Check evaluations: 967. Alpha cutoffs: 66099. Beta cutoffs: 16213. Time elapsed: 2978 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 330887. Check evaluations: 1471. Alpha cutoffs: 11189. Beta cutoffs: 100620. Time elapsed: 2412 ms. Available moves found: 40.

            // 6.1 sec. 24.2. pre
            // Board evaluations: 441370. Check evaluations: 1032. Alpha cutoffs: 66065. Beta cutoffs: 15754. Time elapsed: 3330 ms. Available moves found: 30.
            // Iterative deepening search depth was 5 (30/30). Move evaluation: 120.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 329460. Check evaluations: 1515. Alpha cutoffs: 9652. Beta cutoffs: 105791. Time elapsed: 2769 ms. Available moves found: 40.
            // Iterative deepening search depth was 5 (40/40). Move evaluation: -294,375.

            // 2 sec. Use old alpha-beta for each cycle. -> works for black start, white becomes really stupid
            // Board evaluations: 68415. Check evaluations: 1024. Alpha cutoffs: 24109. Beta cutoffs: 2577. Time elapsed: 736 ms. Available moves found: 30.
            // Iterative deepening search depth was 5 (30/30). Move evaluation: -10.
            // Test: GreatestEndings_1_MidGame. Move: e4 to e2. Depth 5
            // Board evaluations: 132820. Check evaluations: 1517. Alpha cutoffs: 2674. Beta cutoffs: 54639. Time elapsed: 1276 ms. Available moves found: 40.
            // Iterative deepening search depth was 5 (40/40). Move evaluation: 175,625.

            // 11.5 sec. 27.2. Added endgame
            // Test: RuyLopez_Black. Move: f8 to c5. Depth 5
            // Board evaluations: 439696. Check evaluations: 18482. Alpha cutoffs: 65863. Beta cutoffs: 15708. Time elapsed: 3599 ms. Available moves found: 30.
            // Iterative deepening search depth was 5 (30/30). Move evaluation: 120. EndGameKingToCornerEvaluation: -11.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 325754. Check evaluations: 25249. Alpha cutoffs: 10747. Beta cutoffs: 103433. Time elapsed: 2862 ms. Available moves found: 40.
            // Iterative deepening search depth was 5 (40/40). Move evaluation: -290. EndGameKingToCornerEvaluation: 169,5.
            // Test: DoubleRook_EndGame. Move: d8 to c8. Depth 9
            // Board evaluations: 3243904. Check evaluations: 118581. Alpha cutoffs: 276448. Beta cutoffs: 60093. Time elapsed: 5031 ms. Available moves found: 24.
            // Iterative deepening search depth was 6 [partial 7: (1/24)]. Move evaluation: -754,75. EndGameKingToCornerEvaluation: -245,25.
        }
Ejemplo n.º 6
0
        public void RunAll_NoParallel_Transpositions()
        {
            var settings = new LogicSettings()
            {
                UseParallelComputation = false,
                UseTranspositionTables = true,
                UseIterativeDeepening  = false,
                UseFullDiagnostics     = true
            };

            RunAll(5, settings);

            // 22 sec. 22.1.2021
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1723082. Check evaluations: 968. Alpha cutoffs: 43644. Beta cutoffs: 140662. Priority moves found: 107279.
            // Transpositions used: 55172. Time elapsed: 9151 ms. Available moves found: 30. Transposition tables saved: 907124
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 2970965. Check evaluations: 1471. Alpha cutoffs: 222308. Beta cutoffs: 64828. Priority moves found: 81349.
            // Transpositions used: 124315. Time elapsed: 13191 ms. Available moves found: 40. Transposition tables saved: 1441064

            // 22 sec. Added minimax breaks
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1500087. Check evaluations: 968. Alpha cutoffs: 41516. Beta cutoffs: 132503. Priority moves found: 96840.
            // Transpositions used: 36296. Time elapsed: 8382 ms. Available moves found: 30. Transposition tables saved: 864456
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 2969534. Check evaluations: 1471. Alpha cutoffs: 221404. Beta cutoffs: 64788. Priority moves found: 79907.
            // Transpositions used: 124164. Time elapsed: 13357 ms. Available moves found: 40. Transposition tables saved: 1440379

            // 4.2 sec. 24.1.2021 - Keep tabs on alpha&beta values on the minimax launching function
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 152653. Check evaluations: 968. Alpha cutoffs: 2900. Beta cutoffs: 59817. Priority moves found: 32683.
            // Transpositions used: 2800. Time elapsed: 1660 ms. Available moves found: 30. Transposition tables saved: 115932
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 315657. Check evaluations: 1471. Alpha cutoffs: 127543. Beta cutoffs: 4328. Priority moves found: 12446.
            // Transpositions used: 6965. Time elapsed: 2569 ms. Available moves found: 40. Transposition tables saved: 211831

            // 3.7 sec. 16.2.2021 - small move ordering tweak
            // Test: RuyLopez_Black. Move: c6 to d4. Depth 5
            // Board evaluations: 162426. Check evaluations: 967. Alpha cutoffs: 4019. Beta cutoffs: 40293. Priority moves found: 17948.
            // Transpositions used: 3488. Time elapsed: 1570 ms. Available moves found: 30. Transposition tables saved: 127679
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 194290. Check evaluations: 1471. Alpha cutoffs: 77853. Beta cutoffs: 3667. Priority moves found: 8410.
            // Transpositions used: 4316. Time elapsed: 2149 ms. Available moves found: 40. Transposition tables saved: 165471

            // 3.1 sec. 4.3. - major alpha-beta transpositions update
            // Test: RuyLopez_Black. Move: g8 to f6. Depth 5
            // Board evaluations: 39846. Check evaluations: 4658. Alpha cutoffs: 1280. Beta cutoffs: 15634. Transpositions used: 1043.
            // Time elapsed: 1569 ms. Available moves found: 30. Transposition tables saved: 1598.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 56320. Check evaluations: 9479. Alpha cutoffs: 28425. Beta cutoffs: 1783. Transpositions used: 2554.
            // Time elapsed: 1461 ms. Available moves found: 40. Transposition tables saved: 2411.
        }
Ejemplo n.º 7
0
        public void RunAll_Parallel_NoTranspositions()
        {
            var settings = new LogicSettings()
            {
                UseParallelComputation = true,
                UseTranspositionTables = false,
                UseIterativeDeepening  = false,
                UseFullDiagnostics     = true
            };

            RunAll(5, settings);

            // 4.9 sec. 22.1.2021
            // Test: RuyLopez_Black. Move: g8 to e7. Depth 5
            // Board evaluations: 1265055. Check evaluations: 953. Time elapsed: 1929 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: e4 to e2. Depth 5
            // Board evaluations: 2765487. Check evaluations: 1472. Time elapsed: 3004 ms. Available moves found: 40.
        }
Ejemplo n.º 8
0
        public void GreatestEndings_1_MidGame(int searchDepth, LogicSettings settings)
        {
            var board  = new Board();
            var pieces = new List <PieceBase>
            {
                new Pawn(true, "a4"),
                new Pawn(true, "c3"),
                new Pawn(true, "c4"),
                new Pawn(true, "d4"),
                new Pawn(true, "f4"),
                new Pawn(true, "g3"),
                new Pawn(true, "h4"),
                new Pawn(false, "a7"),
                new Pawn(false, "b6"),
                new Pawn(false, "c7"),
                new Pawn(false, "d5"),
                new Pawn(false, "e6"),
                new Pawn(false, "g5"),
                new Pawn(false, "h7"),
                new Pawn(false, "c5"),
                new Rook(true, "a1"),
                new Rook(true, "e1"),
                new Rook(false, "e8"),
                new Rook(false, "f7"),
                new Bishop(true, "d3"),
                new Knight(false, "a5"),
                new Queen(true, "e4"),
                new Queen(false, "d7"),
                new King(true, "g2"),
                new King(false, "f8")
            };

            board.AddNew(pieces);
            var player = new Logic(true, board);

            player.Settings = settings;

            var playerMove  = player.CreateMoveWithDepth(searchDepth);
            var diagnostics = playerMove.Diagnostics;

            Logger.LogMessage($"// Test: {nameof(GreatestEndings_1_MidGame)}. Move: {playerMove.Move.StartPosition} to {playerMove.Move.EndPosition}. Depth {searchDepth}");
            Logger.LogMessage($"// {diagnostics.ToString()}");
        }
Ejemplo n.º 9
0
        private void RunAll(int searchDepth, LogicSettings settings, bool runEndGame = false)
        {
            // Ruy lopez opening
            RuyLopez_Black(searchDepth, settings);

            // https://thechessworld.com/articles/endgame/7-greatest-chess-endings/
            // #1 at pair23
            GreatestEndings_1_MidGame(searchDepth, settings);

            if (runEndGame)
            {
                DoubleRook_EndGame(9, settings);
            }

            // Current standings 17.1.2021 -----------------

            // 15.2 sec normal search
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1265055. Check evaluations: 968. Time elapsed: 5822 ms. Available moves found: 30. Transposition tables saved: 0
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 2765487. Check evaluations: 1471. Time elapsed: 9313 ms. Available moves found: 40. Transposition tables saved: 0

            // 4.3 sec parallel search
            // Test: RuyLopez_Black. Move: c6 to d4. Depth 5
            // Board evaluations: 1265055. Check evaluations: 967. Time elapsed: 1627 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: e4 to e5. Depth 5
            // Board evaluations: 2765487. Check evaluations: 1475. Time elapsed: 2634 ms. Available moves found: 40.

            // 21 sec normal search using transposition tables. Still needs some tuning
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1099116. Check evaluations: 968. Alpha cutoffs: 34157. Beta cutoffs: 103867. Priority moves found: 68067. Time elapsed: 6283 ms. Available moves found: 30. Transposition tables saved: 668577
            // Test: GreatestEndings_1_MidGame. Move: e4 to e5. Depth 5
            // Board evaluations: 2959711. Check evaluations: 1475. Alpha cutoffs: 257178. Beta cutoffs: 65191. Priority moves found: 198480. Time elapsed: 14003 ms. Available moves found: 40. Transposition tables saved: 1569299

            // 20 sec. more logging items
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1099116. Check evaluations: 968. Alpha cutoffs: 34157. Beta cutoffs: 103867. Priority moves found: 68067. Transpositions used: 34501.
            // Time elapsed: 6445 ms. Available moves found: 30. Transposition tables saved: 668577
            // Test: GreatestEndings_1_MidGame. Move: e4 to e5. Depth 5
            // Board evaluations: 2959711. Check evaluations: 1475. Alpha cutoffs: 257178. Beta cutoffs: 65191. Priority moves found: 198480. Transpositions used: 197693.
            // Time elapsed: 14777 ms. Available moves found: 40. Transposition tables saved: 1569299
        }
Ejemplo n.º 10
0
        public void RunAll_NoParallel_NoTranspositions()
        {
            var settings = new LogicSettings()
            {
                UseParallelComputation = false,
                UseTranspositionTables = false,
                UseIterativeDeepening  = false,
                UseFullDiagnostics     = true
            };

            RunAll(5, settings);

            // 14-15 sec. 22.1.2021
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1265055. Check evaluations: 968. Time elapsed: 5705 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 2765487. Check evaluations: 1471. Time elapsed: 9276 ms. Available moves found: 40.

            // 2.7 sec. 24.1.2021 - Keep tabs on alpha&beta values on the minimax launching function
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 155504. Check evaluations: 968. Alpha cutoffs: 58928. Beta cutoffs: 2906. Time elapsed: 1238 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 239509. Check evaluations: 1471. Alpha cutoffs: 3275. Beta cutoffs: 100822. Time elapsed: 1482 ms. Available moves found: 40.
        }
Ejemplo n.º 11
0
            public BotWindowData(string name, GlobalSettings gs, StateMachine sm, Statistics st, StatisticsAggregator sa, WpfEventListener wel, ClientSettings cs, LogicSettings l)
            {
                ProfileName    = name;
                Settings       = new ClientSettings(gs);
                Logic          = new LogicSettings(gs);
                GlobalSettings = gs;
                Machine        = sm;
                Stats          = st;
                Aggregator     = sa;
                Listener       = wel;
                Settings       = cs;
                Logic          = l;

                _ts    = new TimeSpan();
                _timer = new DispatcherTimer {
                    Interval = new TimeSpan(0, 0, 1)
                };
                _timer.Tick += delegate
                {
                    _ts            += new TimeSpan(0, 0, 1);
                    RunTime.Content = _ts.ToString();
                };
                _cts = new CancellationTokenSource();
            }
Ejemplo n.º 12
0
 protected Logic(LogicSettings logicSettings, params IApi[] apis)
 {
     Apis          = new HashSet <IApi>(apis);
     LogicSettings = logicSettings;
 }
Ejemplo n.º 13
0
        public void RunAll_IterativeDeepening()
        {
            var settings = new LogicSettings()
            {
                UseParallelComputation = false,
                UseTranspositionTables = true,
                UseIterativeDeepening  = true,
                UseFullDiagnostics     = true
            };

            RunAll(5, settings, true);

            // 17.4 sec. 22.1.2021 initial algorithm
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 1447494. Check evaluations: 968. Time elapsed: 6706 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 3118588. Check evaluations: 1471. Time elapsed: 10654 ms. Available moves found: 40.


            // 45 sec. transpositions
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 2193664. Check evaluations: 968. Alpha cutoffs: 85401. Beta cutoffs: 172214. Priority moves found: 213821.
            // Transpositions used: 59818. Time elapsed: 12252 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 6602273. Check evaluations: 1471. Alpha cutoffs: 744282. Beta cutoffs: 181376. Priority moves found: 594487.
            // Transpositions used: 246214. Time elapsed: 35217 ms. Available moves found: 40.

            // DEBUG Depth 4 totals
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 4
            // Board evaluations: 221522. Check evaluations: 968. Alpha cutoffs: 44341. Beta cutoffs: 8942. Priority moves found: 59691.
            // Transpositions used: 5950. Time elapsed: 1804 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 4
            // Board evaluations: 630001. Check evaluations: 1471. Alpha cutoffs: 14300. Beta cutoffs: 86228. Priority moves found: 32468.
            // Transpositions used: 30463. Time elapsed: 3666 ms. Available moves found: 40.

            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 2194191. Check evaluations: 968. Alpha cutoffs: 85609. Beta cutoffs: 172275. Priority moves found: 214735.
            // Transpositions used: 59079. Time elapsed: 12294 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 6598637. Check evaluations: 1471. Alpha cutoffs: 743992. Beta cutoffs: 181305. Priority moves found: 590768.
            // Transpositions used: 245099. Time elapsed: 33549 ms. Available moves found: 40.

            // 7.8 sec. 24.1.2021 - Keep tabs on alpha&beta values on the minimax launching function
            // Test: RuyLopez_Black. Move: d8 to f6. Depth 5
            // Board evaluations: 223201. Check evaluations: 968. Alpha cutoffs: 5931. Beta cutoffs: 63272. Priority moves found: 37437.
            // Transpositions used: 4810. Time elapsed: 2087 ms. Available moves found: 30.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 882658. Check evaluations: 1471. Alpha cutoffs: 212237. Beta cutoffs: 17395. Priority moves found: 75884.
            // Transpositions used: 25212. Time elapsed: 5729 ms. Available moves found: 40.

            // 12.3 sec. 27.2. - added endgame
            // Test: RuyLopez_Black. Move: c6 to d4. Depth 5. 5 sec max
            // Board evaluations: 518550. Check evaluations: 25037. Alpha cutoffs: 18161. Beta cutoffs: 74543. Transpositions used: 15766.
            // Time elapsed: 4266 ms. Available moves found: 30. Iterative deepening search depth was 5 (30/30). Move evaluation: 120. EndGameKingToCornerEvaluation: -11.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 328295. Check evaluations: 24681. Alpha cutoffs: 105482. Beta cutoffs: 9801. Transpositions used: 9819.
            // Time elapsed: 2871 ms. Available moves found: 40. Iterative deepening search depth was 5 (40/40). Move evaluation: -290. EndGameKingToCornerEvaluation: 169,5.
            // Test: DoubleRook_EndGame. Move: d5 to g5. Depth 9
            // Board evaluations: 1832377. Check evaluations: 306613. Alpha cutoffs: 17287. Beta cutoffs: 790393. Transpositions used: 819483.
            // Time elapsed: 5116 ms. Available moves found: 24. Iterative deepening search depth was 6 [partial 7: (15/24)]. Move evaluation: -201276,1875. EndGameKingToCornerEvaluation: -272,5.

            // 7.8 sec. 28.2. - improvements based on Eppstein lectures. partially working
            // Test: RuyLopez_Black. Move: g8 to f6. Depth 5
            // Board evaluations: 77271. Check evaluations: 8095. Alpha cutoffs: 2106. Beta cutoffs: 23141. Transpositions used: 6.
            // Time elapsed: 994 ms. Available moves found: 30. Iterative deepening search depth was 5 (30/30). Move evaluation: 65.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 120240. Check evaluations: 13358. Alpha cutoffs: 42173. Beta cutoffs: 2790.
            // Time elapsed: 1380 ms. Available moves found: 40. Iterative deepening search depth was 5 (40/40). Move evaluation: 1135.
            // Test: DoubleRook_EndGame. Move: d7 to f7. Depth 9
            // Board evaluations: 2125891. Check evaluations: 176968. Alpha cutoffs: 752. Beta cutoffs: 525244. Transpositions used: 118747.
            // Time elapsed: 5402 ms. Available moves found: 24. Iterative deepening search depth was 7 [partial 8: (3/24)]. Move evaluation: -201935,0625. EndGameKingToCornerEvaluation: -272,5.

            // 1.1 sec. 4.3. - alpha beta with transpositions major update
            // Test: RuyLopez_Black. Move: g8 to f6. Depth 5
            // Board evaluations: 17970. Check evaluations: 4065. Alpha cutoffs: 992. Beta cutoffs: 12413. Transpositions used: 688.
            // Time elapsed: 315 ms. Available moves found: 30. Iterative deepening search depth was 5 (30/30). Move evaluation: 10.
            // Test: GreatestEndings_1_MidGame. Move: c4 to d5. Depth 5
            // Board evaluations: 35286. Check evaluations: 6768. Alpha cutoffs: 22911. Beta cutoffs: 2043. Transpositions used: 2162.
            // Time elapsed: 452 ms. Available moves found: 40. Iterative deepening search depth was 5 (40/40). Move evaluation: 40.
            // Test: DoubleRook_EndGame. Move: d5 to d3. Depth 9
            // Board evaluations: 110727. Check evaluations: 31327. Alpha cutoffs: 7864. Beta cutoffs: 29061. Transpositions used: 13773.
            // Time elapsed: 288 ms. Available moves found: 24. Iterative deepening search depth was 9 (24/24). Move evaluation: -200007. EndGameKingToCornerEvaluation: -272,5.
        }
Ejemplo n.º 14
0
        public async Task Start(IState initialState, Session session, CancellationToken cancellationToken = default(CancellationToken))
        {
            string workingDirectory       = session.LogicSettings.WorkingDirectory;
            string configurationDirectory = session.LogicSettings.ConfigurationDirectory;

            FileSystemWatcher configWatcher = new FileSystemWatcher();

            configWatcher.Path                = configurationDirectory;
            configWatcher.Filter              = "config.json";
            configWatcher.NotifyFilter        = NotifyFilters.LastWrite;
            configWatcher.EnableRaisingEvents = true;
            configWatcher.Changed            += (sender, e) =>
            {
                if (e.ChangeType == WatcherChangeTypes.Changed)
                {
                    // reload LogicSettings
                    LogicSettings newLogicSettings = new LogicSettings(GlobalSettings.Load(workingDirectory));
                    session.UpdateLogicSettings(newLogicSettings);

                    configWatcher.EnableRaisingEvents = !configWatcher.EnableRaisingEvents;
                    configWatcher.EnableRaisingEvents = !configWatcher.EnableRaisingEvents;

                    Logger.Write(" ##### config.json ##### ", LogLevel.Info);
                }
            };

            IState state = initialState;

            do
            {
                try
                {
                    state = await state.Execute(session, cancellationToken);
                }
                catch (InvalidResponseException)
                {
                    session.EventDispatcher.Send(new ErrorEvent
                    {
                        Message = "Niantic Servers unstable, throttling API Calls."
                    });
                }
                catch (OperationCanceledException)
                {
                    session.EventDispatcher.Send(new ErrorEvent {
                        Message = "Current Operation was canceled."
                    });
                    state = _initialState;
                }
                catch (Exception ex)
                {
                    session.EventDispatcher.Send(new ErrorEvent {
                        Message = "Pokemon Servers might be offline / unstable. Trying again..."
                    });
                    Thread.Sleep(1000);
                    session.EventDispatcher.Send(new ErrorEvent {
                        Message = "Error: " + ex
                    });
                    state = _initialState;
                }
            }while (state != null);

            configWatcher.EnableRaisingEvents = false;
            configWatcher.Dispose();
        }
Ejemplo n.º 15
0
 public RepairLogic(LogicSettings logicSettings, params IApi[] apis) : base(logicSettings, apis)
 {
 }
Ejemplo n.º 16
0
 public RepairLogic(LogicSettings logicSettings) : base(logicSettings)
 {
 }
Ejemplo n.º 17
0
 protected Logic(LogicSettings logicSettings)
 {
     Apis          = new HashSet <IApi>();
     LogicSettings = logicSettings;
 }
Ejemplo n.º 18
0
        public void RuyLopez_Black(int searchDepth, LogicSettings settings)
        {
            // 8R BQ|KBNR
            // 7PPPP| PPP
            // 6  N |
            // 5 B  |P
            // 4    |P
            // 3    | N
            // 2PPPP| PPP
            // 1RNBQ|K  R
            //  ABCD EFGH
            var player = new Logic(false, new Board(CreateRuyLopezOpeningBoard()));

            player.Settings = settings;

            var playerMove  = player.CreateMoveWithDepth(searchDepth);
            var diagnostics = playerMove.Diagnostics;

            Logger.LogMessage($"// Test: {nameof(RuyLopez_Black)}. Move: {playerMove.Move.StartPosition} to {playerMove.Move.EndPosition}. Depth {searchDepth}");
            Logger.LogMessage($"// {diagnostics.ToString()}");
            // 24.10. depth 4
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to b8. Board evaluations: 2025886. Check evaluations: 1023. Time elapsed: 31392 ms. Available moves found: 31.

            // 24.10. depth 5
            // Test: RuyLopez_SearchDepth5_Black. Board evaluations: 19889371. Check evaluations: 1022. Time elapsed: 318569 ms. Available moves found: 31.

            // 24.10. depth 4. Strategy - class
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to b8. Board evaluations: 2025886. Check evaluations: 1023. Time elapsed: 28803,7124 ms. Available moves found: 31.


            // ------- Order prioritizing
            // 24.10. Depth 4 with order prioritize. Edit Board.Moves() - order capture to be first. Seems like really boosts with alpha-beta pruning
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to b8. Board evaluations: 305303. Check evaluations: 1023. Time elapsed: 5451 ms. Available moves found: 31.

            // 24.10. Depth 5 with order prioritize
            // Test: RuyLopez_SearchDepth5_Black. Move: f7 to f6. Board evaluations: 1532427. Check evaluations: 1022. Time elapsed: 26794 ms. Available moves found: 31.


            // ------- Main allMoves-loop parallelized
            // 25.10. Depth 4. All counter methods commented
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to b8. Board evaluations: 305303. Check evaluations: 1023. Time elapsed: 1387 ms. Available moves found: 31.

            // 25.10. Depth 5. All counter methods commented
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to d4. Board evaluations: 1532427. Check evaluations: 1030. Time elapsed: 7002 ms. Available moves found: 31.


            // -------
            // 29.10. depth 4
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to b8. Board evaluations: 191032982. Check evaluations: 1023. Time elapsed: 676506 ms. Available moves found: 31.

            // negate
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to a5. Board evaluations: 13251801. Check evaluations: 1024. Time elapsed: 54043 ms. Available moves found: 31.

            // Skip ordering in check checks
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to a5. Board evaluations: 13250777. Check evaluations: 1024. Time elapsed: 25777 ms. Available moves found: 31.

            // Only reorder moves by evaluation at start depth
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to a5. Board evaluations: 2025917. Check evaluations: 1024. Time elapsed: 10514 ms. Available moves found: 31.


            // Only reorder moves by evaluation at start depth. Otherwise prioritize by capture.
            // Depth 4
            // Test: RuyLopez_SearchDepth5_Black. Move: d8 to f6. Board evaluations: 305334. Check evaluations: 1033. Time elapsed: 1568 ms. Available moves found: 31.
            // Depth 5
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to d4. Board evaluations: 1532458. Check evaluations: 1030. Time elapsed: 7147 ms. Available moves found: 31.
            // --> disabled for now


            // Fix pawn bug
            // 10.1. Depth 5
            // Test: RuyLopez_SearchDepth5_Black. Move: c6 to d4. Board evaluations: 1345201. Check evaluations: 967. Time elapsed: 5653 ms. Available moves found: 30.
        }