Snake eyes game Random error?

Snake eyes game Random error?

I just quickly created a game where the computer rolls two dice until they both land on 1. It works fine however there is one small issue. Sometimes it shows that it got 1,1 and sometimes it doesn’t.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Snake_Eyes

{

class Program

{

static void Main(string[] args)

{

Random rng = new Random();

int dice1 = 0;

int dice2 = 0;

int noa = 0;

while(dice1+dice2 != 2)

{

noa++;

dice1 = rng.Next(0, 7);

dice2 = rng.Next(0, 7);

Console.WriteLine($”You rolled: {dice1} and {dice2}!”);

}

Console.WriteLine($”It took you {noa} times to roll Snake Eyes!”);

Console.ReadKey();

}

}

}

Here it DID display that we got 1,1

Here it DIDN’T display that we got 1,1

submitted by /u/Kaibur02
[link] [comments]

Leave a Reply