Esempio n. 1
0
    /// <summary>
    /// 次の手を取得します
    /// </summary>
    /// <returns>The next move.</returns>
    /// <param name="gameField">Game field.</param>
    public override CellInfo GetNextMove(Game_Field gameField)
    {
        // 盤面シミュレータを作成
        var simulateField = GenerateSimulateFieldWithGameField(gameField);
        // 石を置けるマスを取得
        var puttableCellInfos = simulateField.GetPuttableCellInfos(stoneColor);

        // ランダムで返すのみ
        return(puttableCellInfos[UnityEngine.Random.Range(0, puttableCellInfos.Count)]);
    }
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 next move.</returns>
    /// <param name="gameField">Game field.</param>
    public override CellInfo GetNextMove(Game_Field gameField)
    {
        var simulateField  = GenerateSimulateFieldWithGameField(gameField);
        var cellInfoPoints = new Dictionary <CellInfo, int>();

        foreach (var cellInfo in simulateField.GetPuttableCellInfos(stoneColor))
        {
            var point = 0;

            // 角を取るための重み付け
            if (cellInfo.IsCorner)
            {
                point += 50;
            }

            // 角の斜め隣には出来るだけ打たないための重み付け
            if (cellInfo.IsCornerInside && simulateField.Stage != SimulateField.StageEnum.End)
            {
                point -= 30;
            }

            // 序盤は少なく取るための重み付け
            var tmpField        = GenerateSimulateFieldWithGameField(gameField);
            var turnedCellInfos = tmpField.PutStone(cellInfo.x, cellInfo.y, stoneColor);
            point -= turnedCellInfos.Count * 10;

            // 返す石が相手の石に囲まれている場所を狙う重み付け
            foreach (var cell in turnedCellInfos)
            {
                point += tmpField.CountStoneAroundCell(cell.x, cell.y, stoneColor == Game_Field.StoneColor.Black ? Game_Field.StoneColor.White : Game_Field.StoneColor.Black) * 2;
            }

            // 終盤はたくさん石を取ることを狙う重み付け
            if (simulateField.Stage == SimulateField.StageEnum.End)
            {
                point += turnedCellInfos.Count * 5;
            }

            cellInfoPoints.Add(cellInfo, point);
        }

        // ポイントが一番高いマスを返す
        return(cellInfoPoints.OrderByDescending(x => x.Value).First().Key);
    }
Esempio n. 4
0
 /// <summary>
 /// Used to build the Game Field
 /// </summary>
 private void Construct_Game_Field()
 {
     field = new Game_Field(gui, null); // todo: fix this
     gui.AddGameField(field);
 }
Esempio n. 5
0
 /// <summary>
 /// 次の手を取得します
 /// </summary>
 /// <returns>The next move.</returns>
 /// <param name="gameField">Game field.</param>
 abstract public Game_AI_Base.CellInfo GetNextMove(Game_Field gameField);
Esempio n. 6
0
 public void AddGameField(Game_Field field)
 {
     GameGrid.Controls.Add(field);
     field.Show();
 }