示例#1
0
文件: Rnd.cs 项目: Corniel/game-2048
        public static ulong NextMask(this IGenerator rnd, FreeCells cells)
        {
            var   index = cells[rnd.Next(cells.Count)];
            ulong mask  = rnd.NextCell() << (index * 4);

            return(mask);
        }
示例#2
0
        public Board FillEmptySpot(IGenerator rnd)
        {
            var freeCells = FreeCells.FromBoard(this);

            if (freeCells.Any())
            {
                var bits = Bits | rnd.NextMask(freeCells);
                return(new Board(bits, Score));
            }
            else
            {
                return(Empty);
            }
        }