Exemple #1
0
        private async void newField_Click(object sender, RoutedEventArgs e)
        {
            await AbortGameAsync();

            var muB  = double.TryParse(muT.Text, out var mu);
            var sigB = double.TryParse(sigmaT.Text, out var sig);

            if (!muB)
            {
                MessageBox.Show("μの値が数値ではありません");
                return;
            }

            if (!sigB)
            {
                MessageBox.Show("σの値が数値ではありません");
                return;
            }

            var random = new Core.Algorithms.NormalDistribution()
            {
                Mu     = mu,
                Sigma  = sig,
                UseCos = cosC.IsChecked ?? false
            };

            var field = new Core.Field(new Core.FieldGenerators.RandomFieldGenerator((int)widthS.Value, (int)heightS.Value, random));
            var hw    = widthS.Value / 2;
            var hh    = heightS.Value / 2;

            Random rnd = new Random();

            int agentMaxW = (int)(widthS.Value % 2 == 0 ? hw + 1 : hw);
            int agentMaxH = (int)(widthS.Value % 2 == 0 ? hh + 1 : hh);

            Core.Point agent = new Core.Point(rnd.Next(0, agentMaxH), rnd.Next(0, agentMaxW));

            int crossX = ((int)widthS.Value) - agent.X - 1;
            int crossY = ((int)heightS.Value) - agent.Y - 1;

            var g = new Core.Game(field, new Core.Team(agent, new Core.Point(crossX, crossY)), new Core.Team(new Core.Point(crossX, agent.Y), new Core.Point(agent.X, crossY)));

            await StartGame(g);
        }