Beispiel #1
0
            public void Learn()
            {
                #region Fields
                int    runden = Rundefrage();
                int    zug;
                string momsitcode = SitCodeHelper.GetEmpty(Length);
                int[,] sit_codes = new int[runden, Length];
                int[,] zuege     = new int[runden, Length];
                int[]      wertungen = new int[runden];
                GameStates state     = GameStates.Laufend;
                Game.Game  game      = new Game.Game(new Player('1'), new Player('2'), null, new Fields.SitCode(3, 3));
                #endregion
                OnShowMessageEvent("Berechne Daten..");
                for (int currround = 0; currround < runden; currround++)
                {
                    for (int i = 0; i < 9; i++)
                    {
                        momsitcode = SitCodeHelper.StringToSitCode(game.Field.ToString());
                        sit_codes[currround, i] = int.Parse(momsitcode);
                        zug = FieldHelper.GetRandomZug(game.Field);
                        zuege[currround, i] = zug;

                        game.Logik(Vector2i.FromIndex(zug, 3, 3));

                        state = FieldHelper.GetGameState(game.Field, game.Player);
                        // Wertungen
                        // Aufwerten
                        if (state == GameStates.Gewonnen)
                        {
                            wertungen[currround] = 1;
                        }
                        else if (state == GameStates.Verloren)
                        {
                            wertungen[currround] = -1;
                        }
                        else if (state == GameStates.Unentschieden)
                        {
                            wertungen[currround] = 0;
                        }

                        // Ist Spiel Zu Ende?
                        if (game.HasEnd())
                        {
                            game.NewGame();
                        }
                    }
                    if (currround % 100 == 0)
                    {
                        OnShowMessageEvent("Spielrunde Nr. " + currround);
                    }
                }
                OnShowMessageEvent("Fertig mit dem Berechnen der Daten.");
                OnShowMessageEvent("Speichere Daten");
                writerReader.Write(zuege, sit_codes, wertungen);
                OnShowMessageEvent("Fertig, Taste drücken zum Beenden");
                OnGetStringEvent();
            }
Beispiel #2
0
            public void Learn()
            {
                #region Fields
                int runden = Rundefrage();
                int zug;
                string momsitcode = SitCodeHelper.GetEmpty(Length);
                int[,] sit_codes = new int[runden, Length];
                int[,] zuege = new int[runden, Length];
                int[] wertungen = new int[runden];
                GameStates state = GameStates.Laufend;
                Game.Game game = new Game.Game(new Player('1'), new Player('2'), null, new Fields.SitCode(3, 3));
                #endregion
                OnShowMessageEvent("Berechne Daten..");
                for (int currround = 0; currround < runden; currround++)
                {
                    for (int i = 0; i < 9; i++)
                    {
                        momsitcode = SitCodeHelper.StringToSitCode(game.Field.ToString());
                        sit_codes[currround, i] = int.Parse(momsitcode);
                        zug = FieldHelper.GetRandomZug(game.Field);
                        zuege[currround, i] = zug;

                        game.Logik(Vector2i.FromIndex(zug, 3, 3));

                        state = FieldHelper.GetGameState(game.Field, game.Player);
                        // Wertungen
                        // Aufwerten
                        if (state == GameStates.Gewonnen)
                            wertungen[currround] = 1;
                        else if (state == GameStates.Verloren)
                            wertungen[currround] = -1;
                        else if (state == GameStates.Unentschieden)
                            wertungen[currround] = 0;

                        // Ist Spiel Zu Ende?
                        if (game.HasEnd())
                        {
                            game.NewGame();
                        }
                    }
                    if (currround % 100 == 0)
                    {
                        OnShowMessageEvent("Spielrunde Nr. " + currround);
                    }
                }
                OnShowMessageEvent("Fertig mit dem Berechnen der Daten.");
                OnShowMessageEvent("Speichere Daten");
                writerReader.Write(zuege, sit_codes, wertungen);
                OnShowMessageEvent("Fertig, Taste drücken zum Beenden");
                OnGetStringEvent();
            }