Esempio n. 1
0
        //ToDo: ???TestME
        /// <summary>
        /// Method looks for all connections that include the given tile which would could possibly
        /// be used to win. So this doesn't include any opponent tiles, but will include empty
        /// and own tiles.
        /// </summary>
        /// <param name="board"></param>
        /// <param name="tile"></param>
        static private List <TileConnection> FindAllPossibleWinnableConnectionsForPlayerTile(Game.Board board, Game.Tile tile)
        {
            var allTileConnections = new List <List <Game.Tile> > {
                board.Columns[tile.ColumnNo].Tiles,            //Check vertical
                board.GetRow(tile.RowNo),                      //Check horizontal
                board.GetPositiveDiagonalTilesFromStartingRow( //Check positive diagonal
                    tile.GetPositiveDiagonalStartingRowNo()),
                board.GetNegativeDiagonalTilesFromStartingRow( //Check negative diagonal
                    tile.GetNegativeDiagonalStartingRowNo())
            };

            var winnableConnections = new List <TileConnection>();

            allTileConnections.ForEach(tileSet => {
                var winnableConnection = (new TileConnection(tileSet)).GetWinnableConnectionAround(tile);
                if (winnableConnection != null)
                {
                    winnableConnections.Add(winnableConnection);
                }
            });
            return(winnableConnections);
        }