Ejemplo n.º 1
0
        /// <summary>
        /// アリの移動
        /// </summary>
        private void MoveAnt()
        {
            for (int i = 0; i < this._moveSkip; i++)
            {
                foreach (Ant ant in _ants)
                {
                    int  x;
                    int  y;
                    uint currentColor;

                    x            = ant.X;
                    y            = ant.Y;
                    currentColor = PaintTool.GetCurrentColor(this._antWorldWb, x, y);

                    if (currentColor == ConstValue.BLACK)
                    {
                        ant.TurnRight();
                        PaintTool.PaintDot(ref this._antWorldWb, x, y, ant.Color);
                    }
                    else
                    {
                        ant.TurnLeft();
                        PaintTool.PaintDot(ref this._antWorldWb, x, y, ConstValue.BLACK);
                    }

                    ant.GoStraight(this._antWorldWidth - 1, this._antWorldHeight - 1);
                }
                this._antMoveCount++;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// アリの世界を作る
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public void MakeAntWorld(int width, int height)
 {
     this._antWorldWidth  = width;
     this._antWorldHeight = height;
     this._antWorldWb     = null;
     this._antWorldWb     = new WriteableBitmap(this._antWorldWidth, this._antWorldHeight, 96, 96, PixelFormats.Bgr32, null);
     PaintTool.PaintFull(ref this._antWorldWb, this._antWorldWidth, this._antWorldHeight, PaintTool.MakeColor(0, 0, 0, 0));
     this._ants = null;
     this._ants = new ArrayList();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// アリを追加ボタン
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void makeAntButton_Click(object sender, RoutedEventArgs e)
        {
            int  antCount = this._antSimulate.AntCount;
            uint antColor = ConstValue.WHITE;

            int x = this._random.Next(int.Parse(antWorldWidthText.Text));
            int y = this._random.Next(int.Parse(antWorldHeightText.Text));

            switch (antCount)
            {
            case 0:
                antColor = ConstValue.WHITE;
                break;

            case 1:
                antColor = ConstValue.RED;
                break;

            case 2:
                antColor = ConstValue.GREEN;
                break;

            case 3:
                antColor = ConstValue.BLUE;
                break;

            case 4:
                antColor = ConstValue.MAGENTA;
                break;

            case 5:
                antColor = ConstValue.YELLOW;
                break;

            case 6:
                antColor = ConstValue.CIAN;
                break;

            default:
                antColor = PaintTool.MakeColor((uint)(this._random.Next(256)), (uint)(this._random.Next(256)), (uint)(this._random.Next(256)), 0);
                break;
            }

            if (!this._antSimulate.AddAnt(x, y, this._random.Next(4), antColor))
            {
                MessageBox.Show("アリの世界がありません", "(´・ω・`)", MessageBoxButton.OK);
                return;
            }

            antCount++;
            antCountValueLabel.Content = antCount.ToString();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// アリの自動追加
        /// </summary>
        private void AddAntAuto()
        {
            uint antColor = ConstValue.WHITE;

            int x = this._random.Next(_antWorldWidth);
            int y = this._random.Next(_antWorldHeight);

            switch (this._antTotalCount)
            {
            case 0:
                antColor = ConstValue.WHITE;
                break;

            case 1:
                antColor = ConstValue.RED;
                break;

            case 2:
                antColor = ConstValue.GREEN;
                break;

            case 3:
                antColor = ConstValue.BLUE;
                break;

            case 4:
                antColor = ConstValue.MAGENTA;
                break;

            case 5:
                antColor = ConstValue.YELLOW;
                break;

            case 6:
                antColor = ConstValue.CIAN;
                break;

            default:
                antColor = PaintTool.MakeColor((uint)(this._random.Next(256)), (uint)(this._random.Next(256)), (uint)(this._random.Next(256)), 0);
                break;
            }

            this._antTotalCount++;

            AddAnt(x, y, this._random.Next(4), antColor, this._antlife);
        }