 This is the game of toss-up. It's a game that me and my wife like to play and it is a dice game. The game comes with 10 dice, each die having six sides. The sides are three greens, two yellows, and one red. The way the game is played is that the user wants their turn, the player wants their turn, has the opportunity to roll all 10 dice, and any dice that are green can be put aside as points. And then they can roll, they can choose if they would like to roll the remaining dice. Once you get down to one die, you can choose to roll all 10 again if you'd like. At any point while rolling if you roll any dice and you have a red and no greens like so, you lose and you lose any points you accumulated. The way you lock in your points is by choosing to end your turn before that happens. Games are to 100 points, so theoretically you can get 100 points and win in your first round. And obviously if you have one die, since you have six sides and only one side is red, when you're rolling one die you have a 50% chance of actually getting a green. You've got two yellow sides that would basically be warnings, meaning you don't get any points but you can continue if you'd like, but you only have a one in six chance of losing, meaning that you roll the red side. So the reason I'm telling you about how this game is played, because even though it's easy to figure out my odds with one die, what are my odds rolling two dice or four dice or even when I roll all 10? Obviously the more dice you have, excuse me, the more dice you have the better chance you have of not losing and the better chance you have of getting greens. And with one die the odds are pretty much in your favor, only a one six chance of losing, but when rolling, when playing this game, the question has come up a number of times, what are the odds of me losing when I'm rolling three or five? Should I keep going? Well I thought the best way to do this was to write a simulation program that will simulate the rolling of dice, where the user inputs the number of dice they would like to roll and the number of times they'd like to roll. And you can see the simulation run, get the output, and figure out your percentage of chances of losing and winning. But instead of just writing this in one language, I thought that I'd do something new and write the simulation in three different languages. So for the next couple of weeks we are going to be looking at doing the simulation in Bash, C, and JavaScript and comparing them all. And I can tell you right now that it's not going to be a perfect comparison. The first program I wrote, the script I wrote was in Bash, and then when I wrote it in C I'm not very good with C and it took me a little longer to figure out how to do stuff and I actually think I wrote it more efficient in C, slightly more efficient. And then when I wrote JavaScript I was surprised in how similar my code was to the C. So if I could do it again, if I did do it again, I'd probably write the Bash code more like I wrote the C in JavaScript. Although I don't think that this hurt the performance too much when it comes to run times. I do run tests on how long it takes each program language to run the simulation. And I will tell you that rolling 10 dice 100 times with C was a little less than a second where with Bash it took almost three seconds where with JavaScript in my web browser on my desktop took probably double that. I didn't have an exact number. I had to count it myself but it was a little bit more than Bash. And when I tried rolling a thousand times the JavaScript actually locked up in my browser. So definitely, definitely when it comes to crunching numbers C is going to be more efficient and the more numbers you have the more efficient it will appear or you'll notice. Although Bash isn't too bad with simple calculations like this, JavaScript didn't do that great. Although once again it depends on your browser. But of course the benefit as always with JavaScript is the ease of distribution. So I can put the JavaScript with a little bit HTML up on my website and access it front tip from any computer or device with a current web browser and JavaScript enabled. So my phone for example, so if I met someone's house playing this game and I'm wondering what my odds are with four dice, I can open up my web browser, type in four dice 100 times and see what I get. Where with Bash and C although I could do both of those on my Android phone, I could compile something for an ARM processor for Android or I could just run a shell script with the shell that's on my phone. It's a little more cumbersome. I'd have to open up a shell and type in the information where a web interface is a little more convenient and easy to use. So although my point in making this is not necessarily to compare the speeds of them because obviously C is going to be faster than a scripting language, it's more just to see how I would go through making this simulation in different languages. So there should be an annotation on the screen right now. Click that it will bring you to the playlist. If you're watching this the day I put out this video, there'll be one video on it besides this intro video, which would be our Bash tutorial. And a week from now, I'll put out the C tutorial. And then a week after that, I'll put out the JavaScript tutorial using HTML as the interface. So I hope you enjoy these tutorials and I hope you find them interesting. Let me know what you think as you watch them. And definitely, definitely, if you could write the code better, I would love to see your code, especially the C code, because as again, once again, I am not much of a C programmer. I know just enough to get by. So even though the C code is already more efficient than the JavaScript or the Bash code as is, probably could have been written better would be my guess, even though this is a pretty simple simulation. Anyway, I thank you for watching. And I hope you enjoy this series on simulating the game of toss up. And by the way, I'm not getting paid to promote this game. I just really like it and it's easy to carry around since it will fit in your pocket. So and plus it's kind of addicting. It's like playing a casino game, even though there's no money involved. Anyway, thank you for watching. And I hope you click on that annotation. Have a great day.