Esempio n. 1
0
        public static Task <bool> Solve(FlowBoard board, CancellationToken ct)
        {
            return(Task.Run(() =>
            {
                var solver = new Solver(board)
                {
                    Token = ct
                };

                List <Node> nodes = solver.InitializeNodes();

                solver.SearchForcedPaths(nodes);
                bool foundPaths = solver.Search(nodes);
                if (!foundPaths)
                {
                    board.Reset();
                }

                return foundPaths;
            }, ct));
        }
Esempio n. 2
0
        public void Initialize(FlowBoard board)
        {
            Board = board;
            Board.PropertyChanged += Board_PropertyChanged;
            Field.Columns          = Board.Width;
            Field.Rows             = Board.Height;
            Field.Children.Clear();

            for (int i = 0; i < Field.Columns * Field.Rows; ++i)
            {
                var cell    = Board.Cells[i];
                var element = new CellView();
                element.SetCell(cell);

                element.MouseDown += (object sender, MouseButtonEventArgs e) =>
                {
                    cell.Press();
                };

                Field.Children.Add(element);
            }
        }
Esempio n. 3
0
 private Solver(FlowBoard board)
 {
     Game = board;
     Game.Reset();
 }