Exemplo n.º 1
0
        public Automat2D()
        {
            InitializeComponent();
            CurrentNucleonId = 0;
            GridController   = GridController.GetInstance();
            GridController.SetNeighborhoodType((int)BoundaryConditions.Fixed);
            boundaryComboBox.SelectedIndex           = (int)BoundaryConditions.Fixed;
            randomNeighborhoodComboBox.SelectedIndex = 0;
            NeighborhoodCheckedListBox.SetItemChecked(0, true);
            circleModeExecutionRadioButton.Checked = true;

            pointsToDraw      = new List <Point>();
            xCellTextBox.Text = Grid.SizeX.ToString();
            yCellTextBox.Text = Grid.SizeY.ToString();



            //GRID VIEW
            Zoom = zoomTrackBar.Value;
            GridController.Zoom = Zoom;
            ;
            DrawGridValue           = gridCheckBox.Checked;
            GridController.DrawGrid = DrawGridValue;
            Bitmap gridToDraw = this.GridController.GetGridImage();

            this.gridPictureBox.Size = new Size(gridToDraw.Width, gridToDraw.Height);
            DrawGrid(gridToDraw);

            SetAliveRuleFromTextBox();
            SetDeadRuleFromTextBox();
        }
        public override List <Point> Setup()
        {
            nThreads     = 4;
            calculations = new Task <List <Point> > [nThreads];
            x            = Grid.SizeX / 2;
            y            = Grid.SizeY / 2;

            GridController gc = GridController.GetInstance();

            DeadRule     = gc.DeadRule;
            AliveRule    = gc.AliveRule;
            NextStepGrid = new Grid(Grid.SizeX, Grid.SizeY);
            return(new List <Point>());
        }
Exemplo n.º 3
0
        public override List <Point> Setup()
        {
            List <Point> OriginPoints = GridController.GetInstance().OriginGrains;
            Grid         CurrentGrid  = GridController.GetInstance().CurrentGrid;

            for (int i = FrontPoints.Count - 1; i >= 0; i--)
            {
                if (CurrentGrid.Cells[FrontPoints[i].X, FrontPoints[i].Y].State == 1)
                {
                    FrontPoints.RemoveAt(i);
                }
            }

            return(FrontPoints);
        }
Exemplo n.º 4
0
        public override List <Point> Setup()
        {
            base.Setup();
            Grid         CurrentGrid  = GridController.GetInstance().CurrentGrid;
            List <Point> OriginPoints = GridController.GetInstance().OriginGrains;

            foreach (Point origP in OriginPoints)
            {
                Cell origCell        = CurrentGrid.Cells[origP.X, origP.Y];
                var  neighborsPoints = _Neighborhood.GetNeighborhood(origP.X, origP.Y, Grid.SizeX, Grid.SizeY)
                                       .Where(p => CurrentGrid.Cells[p.X, p.Y].State == 2 || CurrentGrid.Cells[p.X, p.Y].State == 0);
                foreach (Point nP in neighborsPoints)
                {
                    Cell cell = CurrentGrid.Cells[nP.X, nP.Y];
                    cell.ChangeState(2);
                    cell.OriginPosition = origCell.OriginPosition;
                    cell.Id             = origCell.Id;
                    cell.Time           = (int)cell.CurrentPosition.DistanceBettwenPoints(cell.OriginPosition);
                }
                FrontPoints.AddRange(neighborsPoints);
            }
            return(FrontPoints);
        }
Exemplo n.º 5
0
        public override List <Point> Setup()
        {
            base.Setup();
            GridController gc    = GridController.GetInstance();
            var            Angle = (double)gc.RectRotation;

            CosAngle        = Math.Cos(Angle * Math.PI / 180.0);
            SinAngle        = Math.Sin(Angle * Math.PI / 180.0);
            FirstSideRatio  = (double)gc.RectRatioFirst;
            SecondSideRatio = (double)gc.RectRatioSecond;
            SideRatio       = FirstSideRatio / SecondSideRatio;

            YRatio = FirstSideRatio / Math.Max(FirstSideRatio, SecondSideRatio);
            XRatio = SecondSideRatio / Math.Max(FirstSideRatio, SecondSideRatio);

            Grid         CurrentGrid  = GridController.GetInstance().CurrentGrid;
            List <Point> OriginPoints = GridController.GetInstance().OriginGrains;

            foreach (Point origP in OriginPoints)
            {
                Cell origCell        = CurrentGrid.Cells[origP.X, origP.Y];
                var  neighborsPoints = _Neighborhood.GetNeighborhood(origP.X, origP.Y, Grid.SizeX, Grid.SizeY)
                                       .Where(p => CurrentGrid.Cells[p.X, p.Y].State == 2 || CurrentGrid.Cells[p.X, p.Y].State == 0);
                foreach (Point nP in neighborsPoints)
                {
                    Cell cell = CurrentGrid.Cells[nP.X, nP.Y];
                    cell.ChangeState(2);
                    cell.OriginPosition = origCell.OriginPosition;
                    cell.Id             = origCell.Id;
                    cell.Time           = CalculateTime(cell.OriginPosition.X, cell.OriginPosition.Y, nP.X, nP.Y);
                }
                FrontPoints.AddRange(neighborsPoints);
            }

            return(FrontPoints);
        }
Exemplo n.º 6
0
 public RectangleNeighborhood()
 {
     gc = GridController.GetInstance();
     NumberOfNeighbors = 8;
 }
Exemplo n.º 7
0
 public PseudoHeksagonalNeighborhood()
 {
     gc = GridController.GetInstance();
     NumberOfNeighbors = 8;
 }