예제 #1
0
        /// <summary>
        /// The mutate single popup menu was clicked.
        /// </summary>
        /// <param name="sender">The sending object.</param>
        /// <param name="e">The event.</param>
        private void MenuMutateSingle_Click(object sender, RoutedEventArgs e)
        {
            UniverseRunner target = _selectedCell.UniverseRunner;

            target.Mutate(_rnd, target.PhysicsRules, 0.5, 0.2);
            target.Randomize(_rnd);
        }
예제 #2
0
        /// <summary>
        /// The mouse was pressed.
        /// </summary>
        /// <param name="sender">The sending object.</param>
        /// <param name="e">The event.</param>
        private void CanvasOutput_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // update selected cell
            Point pt = Mouse.GetPosition(CanvasOutput);

            int univWidth  = Settings.Default.PaneWidth;
            int univHeight = Settings.Default.PaneHeight;

            _selectedRow = (int)(pt.Y / univWidth);
            _selectedCol = (int)(pt.X / univHeight);

            _selectedCell = _multiverse[_selectedRow][_selectedCol];

            // if left-click then perform correct operation (if any)
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (_copySource != null)
                {
                    UniverseRunner target = _selectedCell
                                            .UniverseRunner;
                    target.PhysicsRules.CopyData(
                        _copySource.PhysicsRules.Data);
                    target.Randomize(_rnd);
                }
                else if (_crossoverParent1 != null &&
                         _crossoverParent2 == null)
                {
                    _crossoverParent2 = _selectedCell.UniverseRunner;
                }
                else
                {
                    UniverseRunner target = _selectedCell.UniverseRunner;
                    target.Crossover(_rnd, _crossoverParent1, _crossoverParent2);
                    target.Randomize(_rnd);
                }
            }
        }