# 1 in a million with two games

**URL:** <https://forum.makecode.com/t/1-in-a-million-with-two-games/3153>\
**Category:** Arcade\
**Tags:** game\
**Created:** [August 18, 2020, 12:35pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153 "2020-08-18T12:35:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 18, 2020, 12:35pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/1 "2020-08-18T12:35:11Z")

</div>

> **[1 in a million](https://arcade.makecode.com/50680-66815-09871-71731)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

  
Actually might be 1 and a million

> **[1 in a million](https://arcade.makecode.com/32314-01031-88243-04936)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

  
Same here as well

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 18, 2020, 4:15pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/2 "2020-08-18T16:15:09Z")

</div>

Tell me if you think this might be a million  
Take a pic

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [August 18, 2020, 8:43pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/3 "2020-08-18T20:43:10Z")

</div>

Fun!

Both games would average out to one chance in a million to win, yes. For the first one, you’re nesting three `1% chance` conditions. That’s 1/100 x 1/100 x 1/100, which is 1/1,000,000.

For the second one, you’re pulling numbers that range between 1 and 1,000,000. There is roughly[1] one chance in a million to pull any single number, so, yes, there is one chance in a million that the numbers will match.

For the first game, you could simplify the logic a little bit:

 ![arcade-screenshot (2)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/18986a89ec7d86abf55d4d47d7f96b943765c4c5.png)

For the second game, you’re only interested in comparing the two numbers when `value2` changes, so you don’t need that comparison in the `on game update` loop. You only need to check when `value2` changes:

 ![arcade-screenshot (3)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1a4fda0d32d91650308bb4a97159cc08170c9d43.png)

Nice work! That was a lot of fun! No, I didn’t win in either game. 🙂

* * *

[1] For those who dig a little deeper, MakeCode Arcade, I believe, relies on JavaScript’s `math.random()` function which, according to Mozilla, is a pseudo-random generator that approximates uniform distribution: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Math/random](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 18, 2020, 9:01pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/4 "2020-08-18T21:01:42Z")

</div>

Thanks @AlexK! The changes in the game sound better. I’m someone who is usually on the safe side. I tried making a 1 in a million game about in July I believe. Thanks for the feedback! I feel like I’m over doing it but thanks for simplifying it!

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 18, 2020, 9:46pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/5 "2020-08-18T21:46:33Z")

</div>

Honestly like short games with short code or long games with long code

---

<div class="post-metadata">

**Author:** ![LcAtonal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/lcatonal/32/16800_2.png) [@LcAtonal](https://forum.makecode.com/u/LcAtonal)\
**Post date:** [August 19, 2020, 7:00am UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/6 "2020-08-19T07:00:09Z")

</div>

Is the first game a template?

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 19, 2020, 11:57am UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/7 "2020-08-19T11:57:31Z")

</div>

No its the game. Press and hold A to roll and the chances of getting to it is actually 1/1000000

---

<div class="post-metadata">

**Author:** ![FlyingFox](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/flyingfox/32/1048_2.png) [@FlyingFox](https://forum.makecode.com/u/FlyingFox)\
**Post date:** [August 19, 2020, 6:02pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/8 "2020-08-19T18:02:24Z")

</div>

I have a messy desk, and happened to have the necessary parts for a test jig at hand. I’ll let you know how long it takes:

[![](https://img.youtube.com/vi/8DoT-ezQLaU/hqdefault.jpg "Testing a game") ](https://www.youtube.com/watch?v=8DoT-ezQLaU)

Jeff 🙂

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 19, 2020, 6:28pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/9 "2020-08-19T18:28:53Z")

</div>

That is the best thing ever! How long do you plan on running that for?

---

<div class="post-metadata">

**Author:** ![FlyingFox](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/flyingfox/32/1048_2.png) [@FlyingFox](https://forum.makecode.com/u/FlyingFox)\
**Post date:** [August 19, 2020, 7:24pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/10 "2020-08-19T19:24:29Z")

</div>

I left it running while I left my office for a bit, and over the course of about an hour, it had tried 15,778 tries without a win. I do need my computer again before the day is out, though, so I stopped it. As fun as mechanical testing is, I think automated testing in software will probably be faster 🙂

Jeff

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [August 19, 2020, 8:50pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/11 "2020-08-19T20:50:28Z")

</div>

Yeah, automated testing will usually be a bit faster 🙂 If anyone wants to run it in dev tools, under the `---simulator`:

```auto
const board = pxsim.board();
let on = true;
setInterval(() => {
    board.setButton(5 / **A** /, on);
    on = !on;
}, 10 / **ms** /);

```

 ![cheating-at-one-in-a-million](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b0c59106ffa5305a59d7b10e390505f4ed5a3d21.gif)

(just a general note for anyone reading, note that running things in dev tools can be a safety concern if you’re e.g. running something on a site with a log in - it’s best to avoid running any code you do not understand / you didn’t write yourself there / just be cautious in general that you aren’t sending your data to someone or anything of the sort.)

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 19, 2020, 8:54pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/12 "2020-08-19T20:54:00Z")

</div>

Man everyone is looking for (well I don’t want to say cheats) new ideas to beat this game.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [August 19, 2020, 8:54pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/13 "2020-08-19T20:54:37Z")

</div>

I mean you may not want to say cheats but I’m not against it; name of the gif in my post:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/ffb3ad1402438faa67801e1c03445473341ac093.png)

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 19, 2020, 8:55pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/14 "2020-08-19T20:55:03Z")

</div>

But seriously, I don’t know javascript or python but that is cool! 😀

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 19, 2020, 8:57pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/15 "2020-08-19T20:57:07Z")

</div>

Big Brains!! I’m not against your javascript but robotics or javascript is a good way to put it.

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 19, 2020, 10:16pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/16 "2020-08-19T22:16:11Z")

</div>

Here is the problem with both of your ideas @jwunderl and @FlyingFox, when you spam A, who knows when you will win? Then there is the part where you do win but never get to see the victory

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [August 20, 2020, 12:18am UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/17 "2020-08-20T00:18:55Z")

</div>

Ah good point, here’s a version that will rain confetti and say you win when it’s over without restarting:

> **[1 in a million](https://arcade.makecode.com/73251-84545-93162-10886)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 20, 2020, 5:10pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/18 "2020-08-20T17:10:09Z")

</div>

That solves the A button problem

---

<div class="post-metadata">

**Author:** ![Dreadmask197](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dreadmask197/32/10494_2.png) [@Dreadmask197](https://forum.makecode.com/u/Dreadmask197)\
**Post date:** [August 20, 2020, 5:10pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/19 "2020-08-20T17:10:55Z")

</div>

Have you been leaving it on all night

---

<div class="post-metadata">

**Author:** ![Kat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kat/32/2596_2.png) [@Kat](https://forum.makecode.com/u/Kat)\
**Post date:** [August 20, 2020, 5:57pm UTC](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153/20 "2020-08-20T17:57:58Z")

</div>

Question: Does it delete the number you roll after you roll it so you get a higher chance of winning as you go on?

[Next page](https://forum.makecode.com/t/1-in-a-million-with-two-games/3153.md?page=2)
