Difference between revisions of "AS 2019 RandomPlayerStarts"
(Created page with "=Where= Find the Game method, and look for: <syntaxhighlight lang=c#> string nextPlayer = "a"; </syntaxhighlight>") |
(→Where) |
||
Line 4: | Line 4: | ||
<syntaxhighlight lang=c#> | <syntaxhighlight lang=c#> | ||
string nextPlayer = "a"; | string nextPlayer = "a"; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | =Idea= | ||
+ | create a random, then generate a random number, and then use it to decide if A or B goes first. | ||
+ | |||
+ | so: | ||
+ | <syntaxhighlight lang=c#> | ||
+ | string nextPlayer; | ||
+ | if (rnd.Next(100) <= 50) | ||
+ | nextPlayer = "a"; | ||
+ | else | ||
+ | nextPlayer = "b"; | ||
+ | Console.WriteLine(nextPlayer + " goes first!!"); | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 08:08, 1 April 2019
Where
Find the Game method, and look for:
string nextPlayer = "a";
Idea
create a random, then generate a random number, and then use it to decide if A or B goes first.
so:
string nextPlayer;
if (rnd.Next(100) <= 50)
nextPlayer = "a";
else
nextPlayer = "b";
Console.WriteLine(nextPlayer + " goes first!!");