So why is my code lying to me? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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/

19th Jun 2017, 3:00 PM
Danijel Hrečuk
Danijel Hrečuk - avatar
9 Answers
+ 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
19th Jun 2017, 2:03 PM
Limitless
Limitless - avatar
+ 2
@Limitless Excellent work, i'm new to c# last 2 weeks so it helped me too.
19th Jun 2017, 2:10 PM
Leon D
Leon D - avatar
+ 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 ...
19th Jun 2017, 1:53 PM
Danijel Hrečuk
Danijel Hrečuk - avatar
+ 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
19th Jun 2017, 2:14 PM
Danijel Hrečuk
Danijel Hrečuk - avatar
+ 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
19th Jun 2017, 2:16 PM
Limitless
Limitless - avatar
0
Can you paste it in the playgrounds then send it.
19th Jun 2017, 1:31 PM
Limitless
Limitless - avatar
0
@Limitless https://code.sololearn.com/cDWWzm6l4Hxl/#cs Also, I get different output on playgrounds than in the visualstudio.
19th Jun 2017, 1:37 PM
Danijel Hrečuk
Danijel Hrečuk - avatar
0
what's supposed to be the output?
19th Jun 2017, 1:39 PM
Limitless
Limitless - avatar
0
Anytime :)
19th Jun 2017, 2:15 PM
Limitless
Limitless - avatar