为 BBC Microbit 开发一个小游戏。
with Ada.Numerics.Discrete_Random
报告"Ada.Numerics" is not a predefined library unit.
Ada 是否提供另一种在 BBC MicroBit 上生成随机数的方法?arch/ARM/Nordic/svd/nrf51/nrf51_svd-rng 定义了一个随机数生成器记录 RNG_Peripheral。这是我正在搜索的内容还是仅与蓝牙一起使用?
GPS 2018 (20180528) hosted on x86_64-pc-linux-gnu
GNAT Community 2018 (20180524-73)
Active toolchain: arm-eabi
the GNAT Programming Studio
(c) 2001-2018 AdaCore
我的代码:
with Ada.Numerics.Discrete_Random;
package body Flip_A_Coin is
package Random_Coin is new Ada.Numerics.Discrete_Random(Coin);
G: Random_Coin.Generator;
------------------
-- Reset --
------------------
procedure Reset is
begin
Random_Coin.Reset(G);
end Reset;
------------------
-- Flip --
------------------
function Flip
return Coin is
begin
return Random_Coin.Random(G);
end Flip;
begin
Reset;
end Flip_A_Coin;