コード例 #1
0
ファイル: Solver.cs プロジェクト: Russell1066/FlowSolver
        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));
        }
コード例 #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);
            }
        }
コード例 #3
0
ファイル: Solver.cs プロジェクト: Russell1066/FlowSolver
 private Solver(FlowBoard board)
 {
     Game = board;
     Game.Reset();
 }