Fix randomInt

This commit is contained in:
Sam El-Husseini
2018-06-01 11:42:38 -07:00
parent b5814709f8
commit 6f148c14e0
61 changed files with 152 additions and 158 deletions

View File

@ -75,8 +75,8 @@ basic.forever(() => {
inside = 0
for (let i = 0; i < n; i++) {
// generate a point within the square
x = Math.randomInt(r + 1)
y = Math.randomInt(r + 1)
x = Math.randomRange(0, r + 1)
y = Math.randomRange(0, r + 1)
// test if the point is within the circle
// sqrt(x**2 + y**2) < r ==> x**2 + y**2 < r**2
if (x * x + y * y < r2) {

View File

@ -4,6 +4,6 @@ Generate a random coordinate and display it on the LED screen.
```blocks
basic.forever(() => {
led.toggle(Math.randomInt(5), Math.randomInt(5))
led.toggle(Math.randomRange(0, 5), Math.randomRange(0, 5))
})
```

View File

@ -24,7 +24,7 @@ input.onButtonPressed(Button.A, () => {
})
basic.forever(() => {
if (start) {
led.toggle(Math.randomInt(5), Math.randomInt(5))
led.toggle(Math.randomRange(0, 5), Math.randomRange(0, 5))
}
})
```