当前位置: 首页>>代码示例>>C#>>正文


C# Move.AddHitPoint方法代码示例

本文整理汇总了C#中Move.AddHitPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Move.AddHitPoint方法的具体用法?C# Move.AddHitPoint怎么用?C# Move.AddHitPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Move的用法示例。


在下文中一共展示了Move.AddHitPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseMoveHint


//.........这里部分代码省略.........
            if (point_strings[point_strings.Length - 1][0] == 'o')
                points.Insert(points.Count, -1);
            // points should be sorted from highest to lowest at this point

            // calculate the missing way points
            if (dice[0] != dice[1])
            {
                if (count == 1 && points.Count == 2)
                {
                    int distance = points[0] - points[1];
                    int bigger_die = Math.Max(dice[0], dice[1]);
                    int smaller_die = Math.Min(dice[0], dice[1]);
                    if (distance > bigger_die)//(points[0] - points[1]) == (dice[0] + dice[1]))
                    {
                        if (distance == (dice[0] + dice[1]))
                        {
                            // Must not contain hits, because gnubg tells about the hit points seperately.
                            if (gamestate.Board.PointCount(gamestate.PlayerOnRoll, points[0] - bigger_die) >= 0)
                                points.Insert(0, (points[0] - bigger_die));
                            else
                                points.Insert(0, (points[0] - smaller_die));
                        }
                        else if (points[0] - bigger_die < smaller_die) // bearoff from 6 with 52, need first to do the smaller one.
                        {
                            if (gamestate.Board.PointCount(gamestate.PlayerOnRoll, points[0] - smaller_die) >= 0) // Was broken without this condition on _ _ 8x 2o 2o 2o with dice 43
                                points.Insert(0, (points[0] - smaller_die));
                            else if (gamestate.Board.PointCount(gamestate.PlayerOnRoll, points[0] - smaller_die) == -1)
                                points.Insert(0, (points[0] - bigger_die));
                            else
                            {
                            }
                        }
                        else
                        {
                            throw new InvalidOperationException("Cannot handle this. Help!");
                        }
                        /*if (gamestate.Board.PointCount(gamestate.PlayerOnRoll, points[0] - bigger_die) > -2)
                            points.Insert(0, (points[0] - bigger_die));
                        else
                            points.Insert(0, (points[0] - smaller_die));*/
                    } // This is for lonely bearoffs like |_ _ x _ x x| with 41, gnubg gives one of the hints as '4/off'.
                        // We want atleast 2 chequers on the field because otherwise adding a waypoint is unnecessary inbetween.
                    else if (total_hints == 1 && gamestate.Board.FinishedCount(gamestate.PlayerOnRoll) <= 13 && points[1] == -1 && (points[0] - smaller_die >= 0) && gamestate.Board.PointCount(gamestate.PlayerOnRoll, points[0] - smaller_die) >= 0 && gamestate.Board.LastChequer(gamestate.PlayerOnRoll) <= points[0])
                    {
                        points.Insert(0, (points[0] - smaller_die));
                    }
                    else
                    {

                    }
                }
            }
            else
            {
                for (int i = 0; i < points.Count - 1; i++)
                {
                    // This was broken with bearoffs without this condition (ie. 6/off with 44, the below else condition should handle this situation)
                    /*if (points[i + 1] > -1)
                    {*/
                        int gaps = (points[i] - points[i + 1]) / dice[0];
                        int mod = (points[i] - points[i + 1]) % dice[0];
                        if (mod > 0)
                            gaps++;

                        if (gaps > 1)
                        {
                            for (int c = 1; c < gaps; c++)
                            {
                                points.Insert(i + 1, points[i] - dice[0]);
                                i++;
                            }
                        }
                    /*}
                    else
                    {
                        int gaps = (points[i] - points[i + 1]) / dice[0];
                        int mod = (points[i] - points[i + 1]) % dice[0];
                        if (mod > 0)
                        {
                            for (int c = 0; c < gaps; c++)
                            {
                                points.Insert(i + 1, points[i] - dice[0]);
                                i++;
                            }
                        }
                    }*/
                }
            }

            Move move = new Move();
            foreach (int point in points)
            {
                if (hitpoints.Contains(point))
                    move.AddHitPoint(point);
                else
                    move.AddPoint(point);
            }

            return move;
        }
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:101,代码来源:GnuBG.cs

示例2: Form1_MouseClick

        void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            if (currentGameState.PlayerOnTurn == 0 && !currentGameState.HasOffer && currentGameState.DiceRolled && legalPlays.Count > 0 && madeMoves.Count < legalPlays[0].Count)
            {
                BoundingChequer chequer = ClickTest(e.Location);
                if (chequer == null)
                    return;

                int[] dice = currentGameState.Dice;

                int from = chequer.Slot;

                if (dice[0] != dice[1])
                {
                    int die = -1;
                    if (unusedDice.Count == 2)
                    {
                        if (e.Button == MouseButtons.Left)
                            die = Math.Max(unusedDice[0], unusedDice[1]);
                        else if (e.Button == MouseButtons.Right)
                            die = Math.Min(unusedDice[0], unusedDice[1]);
                        else
                            return;
                    }
                    else
                        die = unusedDice[0];

                    int to = chequer.Slot - die;
                    if (to < -1)
                        to = -1;

                    Move move = new Move(from, to);

                    if (currentGameState.Board.IsLegalMove(currentGameState.PlayerOnRoll, move, die))
                    {
                        if (to >= 0 && currentGameState.Board.PointCount(currentGameState.PlayerOnRoll, to) == -1)
                            move.AddHitPoint(to);

                        watch.Stop();

                        /*Stack<Move> s = new Stack<Move>();
                        foreach (Move m in madeMoves.Reverse())
                            s.Push(m.Clone());*/

                        List<TimedMove> h = new List<TimedMove>();
                        foreach (TimedMove m in moveHistory)
                            h.Add(new TimedMove(m));

                        TimedMove tmove = new TimedMove(move, (int)watch.ElapsedMilliseconds, 0);

                        moves.Add(new GameStateMoveAction(currentGameState.Clone(), originalGameState, watch.ElapsedMilliseconds, tmove, h));

                        currentGameState.Board.MakeMove(currentGameState.PlayerOnRoll, move);
                        madeMoves.Push(move);
                        moveHistory.Add(tmove);

                        unusedDice.Remove(die);
                        usedDice.Push(die);

                        UpdateControls();
                    }
                    else
                    {
                        if (unusedDice.Count == 2)
                        {
                            die = (dice[0] == die) ? dice[1] : dice[0];

                            to = chequer.Slot - die;
                            if (to < -1)
                                to = -1;

                            move = new Move(from, to);

                            if (currentGameState.Board.IsLegalMove(currentGameState.PlayerOnRoll, move, die))
                            {
                                if (to >= 0 && currentGameState.Board.PointCount(currentGameState.PlayerOnRoll, to) == -1)
                                    move.AddHitPoint(to);

                                watch.Stop();
                                /*Stack<Move> s = new Stack<Move>();
                                foreach (Move m in madeMoves.Reverse())
                                    s.Push(m.Clone());*/

                                //moves.Add(new GameStateMoveAction(currentGameState.Clone(), watch.ElapsedMilliseconds, move.Clone(), s));

                                List<TimedMove> h = new List<TimedMove>();
                                foreach (TimedMove m in moveHistory)
                                    h.Add(new TimedMove(m));

                                TimedMove tmove = new TimedMove(move, (int)watch.ElapsedMilliseconds, 0);

                                moves.Add(new GameStateMoveAction(currentGameState.Clone(), originalGameState, watch.ElapsedMilliseconds, tmove, h));

                                currentGameState.Board.MakeMove(currentGameState.PlayerOnRoll, move);
                                madeMoves.Push(move);
                                moveHistory.Add(tmove);

                                unusedDice.Remove(die);
                                usedDice.Push(die);

//.........这里部分代码省略.........
开发者ID:alexhanh,项目名称:Botting-Library,代码行数:101,代码来源:Form1.cs


注:本文中的Move.AddHitPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。