Example #1
0
        [Test] public void TestFixes1()
        {
            var graph = WordGraph.French;
            var board = new Board();
            var rack  = new Rack("ASSDHS");

            var part1 = new WordPart("DAHS", new Cell(4, 4), Direction.Down);

            board = board.Play(part1);

            rack = new Rack("SSEEEA");
            PlayGraph play       = new PlayGraph(graph, board, rack);
            var       moveFinder = new MoveFinder(graph, board, play);
            List <Tuple <PlayInfo, PlayPath> > moves = moveFinder.GetAllMoves();

            foreach (Tuple <PlayInfo, PlayPath> move in moves)
            {
                if ("ES" != move.Item2.Main.Word ||
                    new Cell(7, 5) != move.Item2.Main.First ||
                    Direction.Down != move.Item2.Main.Direction)
                {
                    continue;
                }
                Assert.IsTrue(move.Item1.HasFixes);
                Assert.IsTrue(move.Item1.HasTwoMoreFixes);
            }
        }
Example #2
0
        [Test] public void TestFixes2()
        {
            var graph = WordGraph.French;
            var board = new Board();
            var rack  = new Rack("DELRIC");

            var part1 = new WordPart("DECRI", new Cell(4, 4), Direction.Right);

            board = board.Play(part1);

            rack = new Rack("LTREIG");
            PlayGraph play       = new PlayGraph(graph, board, rack);
            var       moveFinder = new MoveFinder(graph, board, play);
            List <Tuple <PlayInfo, PlayPath> > moves = moveFinder.GetAllMoves();

            foreach (Tuple <PlayInfo, PlayPath> move in moves)
            {
                if ("GILET" != move.Item2.Main.Word ||
                    new Cell(5, 1) != move.Item2.Main.First ||
                    Direction.Right != move.Item2.Main.Direction)
                {
                    continue;
                }
                Assert.IsTrue(move.Item1.HasFixes);
                Assert.IsFalse(move.Item1.HasTwoMoreFixes);
            }
        }
Example #3
0
        private static Board TestPlayIgnoreExtra(IList <Tuple <string, string, Cell, Direction> > plays)
        {
            var graph = WordGraph.French;
            var board = new Board();
            var rack  = new Rack(plays[0].Item1);

            var part1 = new WordPart(plays[0].Item2, plays[0].Item3, plays[0].Item4);

            board = board.Play(part1);

            for (int i = 1; i < plays.Count; i++)
            {
                rack = new Rack(plays[i].Item1);
                PlayGraph play       = new PlayGraph(graph, board, rack);
                var       moveFinder = new MoveFinder(graph, board, play);
                List <Tuple <PlayInfo, PlayPath> > moves = moveFinder.GetAllMoves();
                foreach (Tuple <PlayInfo, PlayPath> move in moves)
                {
                    PlayPath path = move.Item2;
                    if (plays[i].Item2 != path.Main.Word ||
                        plays[i].Item3 != path.Main.First ||
                        plays[i].Item4 != path.Main.Direction)
                    {
                        continue;
                    }
                    board = board.Play(path);
                    if (i != plays.Count - 1)
                    {
                        continue;
                    }
                    Assert.GreaterOrEqual(board.Score.Other.Points, 0);
                    Assert.GreaterOrEqual(board.Score.Current.Points, 0);
                    return(board);
                }
            }
            throw new InvalidOperationException("Move not found");
        }