コード例 #1
0
ファイル: FlingAI.cs プロジェクト: sezeresen/FlingSolver
        public static List<FlingMove> SearchMoves(CellCollection cells)
        {
            List<FlingMove> _result = new List<FlingMove>();

            foreach (Cell item in cells)
            {
                if (!item.IsEmpty)
                {
                    foreach (Directions dir in DirectionManager.AllDirections)
                    {
                        if (DirectionManager.IsCrosswise(dir))
                            continue;

                        Cell _startBall = item;
                        Cell _hitBall = item;
                        FlingMove _parentMove = null;
                        FlingMove _activeMove = null;
                        int _moveCount = 0;

                        while (cells.RoverCell(ref _hitBall, dir))
                        {
                            _moveCount++;
                            if (!_hitBall.IsEmpty)
                            {
                                if (_parentMove != null ||
                                    _moveCount > 1)
                                {
                                    FlingMove _move = new FlingMove()
                                    {
                                        StartBall = _startBall,
                                        Dir = dir,
                                        MoveCount = _moveCount,
                                        HitBall = _hitBall,
                                    };

                                    if (_parentMove == null)
                                    {
                                        _parentMove = _activeMove = _move;
                                        _result.Add(_parentMove);
                                    }
                                    else
                                    {
                                        _activeMove.RelatedMove = _activeMove = _move;
                                    }
                                    _moveCount = 0;
                                    _startBall = _hitBall;
                                }
                                else
                                    break;
                            }
                        }
                    }
                }
            }

            return _result;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: sezeresen/FlingSolver
        public void AddFlingMoveToList(FlingMove move)
        {
            ListViewItem _lvi = new ListViewItem(move.StartBall.ToString());
            _lvi.SubItems.Add(move.Dir.ToString());
            _lvi.SubItems.Add(move.HitBall.ToString());
            _lvi.SubItems.Add(move.RelatedMove == null ? "---" : "+++");
            _lvi.Tag = move;

            listView1.Items.Add(_lvi);
        }
コード例 #3
0
ファイル: FlingBoard.cs プロジェクト: sezeresen/FlingSolver
        public void RollbackMove(FlingMove move)
        {
            if (move.MoveCount > 1)
            {
                move.StartBall.Shape = this.m_defaultShape;
                Cell _end = move.HitBall;
                base.Cells.RoverCell(ref _end, move.Dir, -1);
                _end.Shape = CellShapes.empty;
            }

            if (move.RelatedMove != null)
            {
                this.RollbackMove(move.RelatedMove);
            }
            else
            {
                move.HitBall.Shape = this.m_defaultShape;
            }

            base.RefreshBoard();
        }
コード例 #4
0
ファイル: FlingBoard.cs プロジェクト: sezeresen/FlingSolver
        public void SelectMove(FlingMove move, bool forRoleback)
        {
            this.m_selectedMove = move;
            this.m_selectedForRoleback = forRoleback;

            base.RefreshBoard();
        }
コード例 #5
0
ファイル: FlingBoard.cs プロジェクト: sezeresen/FlingSolver
 public void SelectMove(FlingMove move)
 {
     this.SelectMove(move, false);
 }