Esempio n. 1
0
 /// <summary>
 /// 石を置きます
 /// </summary>
 /// <returns>The stone.</returns>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 /// <param name="stoneColor">Stone color.</param>
 public List <CellInfo> PutStone(int x, int y, Game_Field.StoneColor stoneColor)
 {
     if (!IsStonePuttable(x, y, stoneColor))
     {
         throw new Exception(string.Format("Cannot put {0} stone to [{1},{2}].", stoneColor.ToString(), x, y));
     }
     cells[x, y] = stoneColor;
     return(TurnOverStoneIfPossible(x, y));
 }
Esempio n. 2
0
    /// <summary>
    /// Game_Fieldオブジェクトを元に盤面シミュレータを作成します
    /// </summary>
    /// <returns>The simulate field with game field.</returns>
    /// <param name="gameField">Game field.</param>
    protected SimulateField GenerateSimulateFieldWithGameField(Game_Field gameField)
    {
        var cells = new Game_Field.StoneColor[Game_Field.SIZE_X, Game_Field.SIZE_Y];

        foreach (var cell in gameField.cells)
        {
            cells[cell.X, cell.Y] = cell.StoneColor;
        }
        return(new SimulateField(cells));
    }
Esempio n. 3
0
        /// <summary>
        /// 石を置けるマスを返します
        /// </summary>
        /// <returns>The puttable cell infos.</returns>
        /// <param name="stoneColor">Stone color.</param>
        public List <CellInfo> GetPuttableCellInfos(Game_Field.StoneColor stoneColor)
        {
            var infos = new List <CellInfo>();

            for (var x = 0; x < Game_Field.SIZE_X; x++)
            {
                for (var y = 0; y < Game_Field.SIZE_Y; y++)
                {
                    if (IsStonePuttable(x, y, stoneColor))
                    {
                        infos.Add(new CellInfo(x, y, stoneColor));
                    }
                }
            }
            return(infos);
        }
Esempio n. 4
0
 /// <summary>
 /// 指定のマスに石が置けるかどうかをチェックします
 /// </summary>
 /// <returns><c>true</c> if this instance is stone puttable the specified x y stoneColor; otherwise, <c>false</c>.</returns>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 /// <param name="stoneColor">Stone color.</param>
 bool IsStonePuttable(int x, int y, Game_Field.StoneColor stoneColor)
 {
     if (IsCorrectCoordinate(x, y) && cells[x, y] == Game_Field.StoneColor.None)
     {
         return(ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, -1, -1) ||
                ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, -1, 0) ||
                ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, -1, 1) ||
                ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, 0, -1) ||
                ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, 0, 1) ||
                ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, 1, -1) ||
                ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, 1, 0) ||
                ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(x, y, stoneColor, 1, 1));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 5
0
    // マスに配置されている石の色

    public void SetStoneColor(Game_Field.StoneColor color)
    {
        switch (color)
        {
        case Game_Field.StoneColor.None:
            stone.gameObject.SetActive(false);
            break;

        case Game_Field.StoneColor.Black:
            stone.gameObject.SetActive(true);
            stone.color = Color.black;
            break;

        case Game_Field.StoneColor.White:
            stone.gameObject.SetActive(true);
            stone.color = Color.white;
            break;
        }
    }
Esempio n. 6
0
        /// <summary>
        /// 自分(指定色)の石が相手の石を挟める場所にあるかチェックします
        /// </summary>
        /// <returns><c>true</c>, if own stone at the other side of enemy stone for direction was existsed, <c>false</c> otherwise.</returns>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="stoneColor">Stone color.</param>
        /// <param name="xDirection">X direction.</param>
        /// <param name="yDirection">Y direction.</param>
        bool ExistsOwnStoneAtTheOtherSideOfEnemyStoneForDirection(int x, int y, Game_Field.StoneColor stoneColor, int xDirection, int yDirection)
        {
            var existsEnemyStone = false;

            while (true)
            {
                x += xDirection;
                y += yDirection;
                if (!IsCorrectCoordinate(x, y) || cells[x, y] == Game_Field.StoneColor.None)
                {
                    return(false);
                }
                else if (cells[x, y] == stoneColor)
                {
                    return(existsEnemyStone);
                }
                else
                {
                    existsEnemyStone = true;
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 指定マスの周り8マスに指定した色の石が何個あるか数えます
        /// </summary>
        /// <returns>The stone around cell.</returns>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="stoneColor">Stone color.</param>
        public int CountStoneAroundCell(int x, int y, Game_Field.StoneColor stoneColor)
        {
            var count = 0;

            for (var xDiff = -1; xDiff <= 1; xDiff++)
            {
                for (var yDiff = -1; yDiff <= 1; yDiff++)
                {
                    var nextX = x + xDiff;
                    var nextY = y + yDiff;
                    if (!IsCorrectCoordinate(nextX, nextY))
                    {
                        continue;
                    }
                    if ((xDiff != 0 || yDiff != 0) && cells[nextX, nextY] == stoneColor)
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
Esempio n. 8
0
 public Game_AI_Theory(Game_Field.StoneColor stoneColor)
 {
     this.stoneColor = stoneColor;
 }
Esempio n. 9
0
 public Game_AI_Random(Game_Field.StoneColor stoneColor)
 {
     this.stoneColor = stoneColor;
 }
Esempio n. 10
0
 public CellInfo(int x, int y, Game_Field.StoneColor stoneColor)
 {
     this.x          = x;
     this.y          = y;
     this.stoneColor = stoneColor;
 }
Esempio n. 11
0
 /// <summary>
 /// 指定した色の石を数えます
 /// </summary>
 /// <returns>The stone.</returns>
 /// <param name="stoneColor">Stone color.</param>
 public int CountStone(Game_Field.StoneColor stoneColor)
 {
     return(cells.Cast <Game_Field.StoneColor>().Count(x => x == stoneColor));
 }