+ 1
So why is my code lying to me?
-The program does give me a random score for two teams and if I run the program multiple times I would get different scores for the blue and red team. -So instead of running it 10 times, I wanted to just call "MatchEvent" 10 times but then I just get same random score 10 times. -At same time If I "WriteLine(machScore);" which is boolean, I get what I want but with "machScore" true or false spam. https://code.sololearn.com/cDWWzm6l4Hxl/#cs Also, I get different output on playgrounds than in the visualstudio. SOLUTION: Added using System.Threading; and Thread.Sleep(10); to a code. Works better in virsualstudio than playgrounds. Credit: @Limitless https://www.sololearn.com/Profile/5063428/
9 Respuestas
+ 2
Try this on Visual Studios.
(It won't work on Sololearn due to time limit)
When you create a Random instance they take the current time (to milliseconds) and throw out a random integer.
Add a bit of delay and you'll get different results each time
https://code.sololearn.com/c5zZl05V9otF/?ref=app
+ 2
@Limitless Excellent work, i'm new to c# last 2 weeks so it helped me too.
+ 1
@Limitless
I want the output to be:
BLUE POINTS:131 RED POINTS:89
BLUE POINTS:92 RED POINTS:187
BLUE POINTS:145 RED POINTS:54 ...
Random scores for teams ... but I get
BLUE POINTS:131 RED POINTS:89
BLUE POINTS:131 RED POINTS:89
BLUE POINTS:131 RED POINTS:89 ...
+ 1
@Limitless
Ty for the help, it works on both visualstudio and sololearn, I'm beginner programmer so I have much more to learn :D
+ 1
I had to learn it the hard way.
But I have been coding in C# for a year now so you guys can always press on my button if you need help
0
Can you paste it in the playgrounds then send it.
0
@Limitless
https://code.sololearn.com/cDWWzm6l4Hxl/#cs
Also, I get different output on playgrounds than in the visualstudio.
0
what's supposed to be the output?
0
Anytime :)