Exemplo n.º 1
0
 public double GetPoints(Mancala game, bool player1)
 {
     if (game.CheckEnd())
     {
         if (player1)
         {
             return(game.Player1Well[0] + game.Player1Holes.Sum(x => x) - game.Player2Well[0] - game.Player2Holes.Sum(x => x));
         }
         else
         {
             return(game.Player2Well[0] + game.Player2Holes.Sum(x => x) - game.Player1Well[0] - game.Player1Holes.Sum(x => x));
         }
     }
     else
     {
         if (player1)
         {
             return(game.Player1Well[0] - game.Player2Well[0]);
         }
         else
         {
             return(game.Player2Well[0] - game.Player1Well[0]);
         }
     }
 }
Exemplo n.º 2
0
        public double GetPoints(Mancala game, bool player1)
        {
            double result = 0;

            if (player1)
            {
                // Winning it's good
                if (game.CheckEnd())
                {
                    return(game.Player1Well[0] + game.Player1Holes.Sum(x => x) - game.Player2Well[0] - game.Player2Holes.Sum(x => x));
                }
                // Game continue, so we calculate points like above functions

                // Adding points when we have it
                double raisingVal = 1;
                for (int i = 0; i < game.Player1Holes.Length; i++)
                {
                    if (game.Player1Holes[i] == i + 1)
                    {
                        result += raisingVal;
                        // Because it can combo up
                        if (i > 0 && game.Player1Holes[0] == 0)
                        {
                            result += ComboValue;
                        }
                    }
                    raisingVal += 0.5;
                }
                result += game.Player1Holes.Sum(x => x) * this.HoleValue;
                result += game.Player1Well[0] * WellValue;

                // Subtracting points from
                raisingVal = 1;
                for (int i = game.Player1Holes.Length - 1; i >= 0; i--)
                {
                    if (game.Player2Holes[i] == i + 1)
                    {
                        result -= raisingVal;
                        // Because it can combo up
                        if (i > 0 && game.Player2Holes[0] == 0)
                        {
                            result -= ComboValue;
                        }
                    }
                    raisingVal += 0.5;
                }
                result -= game.Player2Holes.Sum(x => x) * this.HoleValue;
                result -= game.Player2Well[0] * WellValue;

                return(result);
            }
            else
            {
                if (game.CheckEnd())
                {
                    return(game.Player2Well[0] + game.Player2Holes.Sum(x => x) - game.Player1Well[0] - game.Player1Holes.Sum(x => x));
                }
                // Game continue, so we calculate points like above functions

                // Abosite adding and Subtracting, than above
                double raisingVal = 1;
                for (int i = 0; i < game.Player2Holes.Length; i++)
                {
                    if (game.Player1Holes[i] == i + 1)
                    {
                        result -= raisingVal;
                        // Because it can combo up
                        if (i > 0 && game.Player1Holes[0] == 0)
                        {
                            result -= ComboValue;
                        }
                    }
                    raisingVal -= 0.5;
                }
                result -= game.Player1Holes.Sum(x => x) * this.HoleValue;
                result -= game.Player1Well[0] * WellValue;

                // Subtracting points from
                raisingVal = 1;
                for (int i = game.Player2Holes.Length - 1; i >= 0; i--)
                {
                    if (game.Player2Holes[i] == i + 1)
                    {
                        result += raisingVal;
                        // Because it can combo up
                        if (i > 0 && game.Player2Holes[0] == 0)
                        {
                            result += ComboValue;
                        }
                    }
                    raisingVal += 0.5;
                }
                result += game.Player2Holes.Sum(x => x) * this.HoleValue;
                result += game.Player2Well[0] * WellValue;

                return(result);
            }
        }