private static Random random = new Random();
public static void Main(String[] args)
player = random.Next(2) + 1;
range = maxRange - minRange + 1;
Console.WriteLine("Since I am going first, enter the number of chips to start with on the table between 15 and 24");
while (! (chips >= 15 && chips <= 24))
Console.WriteLine("That is not a valid selection, please try again: ");
Console.WriteLine("Enter the maximun number of chips to remove each turn, between " + minRange + " and " + maxRange + ": ");
while (! (maxChips >= minRange && maxChips <= maxRange))
Console.WriteLine("That is not a valid selection, please try again: ");
chips = random.Next(8) + 15;
Console.WriteLine("Since you are going first, I have decided that we will start with >" + chips + "< on the table.");
maxChips = random.Next(range) + minRange;
Console.WriteLine("The maximun number of chips we are allowed to remove from the table during our turn is: " + maxChips);
if (chips - maxChips <= maxChips + 1)
chipsRemoved = chips - maxChips - 1;
chipsRemoved = random.Next(maxChips) + 1;
Console.WriteLine("My turn, I am removing >" + chipsRemoved + "< chips.");
Console.WriteLine("Your turn, enter the number of chips to remove from the table: ");
while (! (chipsRemoved <= chips))
Console.WriteLine("That is not a valid selection, you cannot remove more chips then are left on the table. Please try again. Enter a number (up to " + chips + ") of chips to remove from the table: ");
while (! (chipsRemoved >= 1 && chipsRemoved <= maxChips))
Console.WriteLine("That is not a valid selection, please try again. Enter a number up to " + maxChips + ": ");
chips = chips - chipsRemoved;
Console.WriteLine("There are now >" + chips + "< on the table.");
Console.WriteLine("I won, must have been my excellent skill.");
Console.WriteLine("You won. Good for you. You are very talented.");
private static void input(out double result)
while (!double.TryParse(Console.ReadLine(), out result));
private static void input(out int result)
while (!int.TryParse(Console.ReadLine(), out result));
private static void input(out Boolean result)
while (!Boolean.TryParse(Console.ReadLine(), out result));
private static void input(out string result)
result = Console.ReadLine();