2016-04-05 06:18:16 +02:00
|
|
|
namespace console {
|
|
|
|
export function log(msg: string) {
|
|
|
|
serial.writeString(msg);
|
|
|
|
serial.writeString("\r\n");
|
|
|
|
}
|
|
|
|
}
|
2016-05-27 04:49:38 +02:00
|
|
|
|
|
|
|
namespace Math {
|
|
|
|
/**
|
|
|
|
* Generates a `true` or `false` value randomly, just like flipping a coin.
|
|
|
|
*/
|
|
|
|
//% blockId=logic_random block="pick random true or false"
|
2018-04-21 19:25:43 +02:00
|
|
|
//% help=math/random-boolean weight=0
|
2016-05-27 04:49:38 +02:00
|
|
|
export function randomBoolean(): boolean {
|
2018-06-04 20:47:12 +02:00
|
|
|
const v = Math.randomRange(0, 1) * 2;
|
|
|
|
return 1 == Math.floor(v);
|
2018-04-21 19:45:02 +02:00
|
|
|
}
|
2016-05-27 04:49:38 +02:00
|
|
|
}
|