为BBC Microbit做一个小游戏。
with Ada.Numerics.Discrete_Random reports "Ada.Numerics" is not a predefined library unit.
Ada是否提供了在BBC MicroBit上生成随机数的另一种方法?arch/ARM/Nordic/svd/nRF51/nRF51Svd-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;发布于 2019-01-02 01:41:20
如果您使用
for Runtime ("ada") use "ravenscar-full-microbit";在您的项目或
--RTS=ravenscar-full-microbit在命令行中,您将找到标准的Ada RNGs。
您还可以按照您的建议,尝试使用Ada Drivers Library中的NRF51_SVD.RNG,这应该可以做到这一点。
发布于 2019-01-01 23:33:11
如果您有可用的浮点数,您可以使用@ Mathpaqs提供的U_Rand。
发布于 2019-01-05 01:18:52
在PragmAda可重用组件中有许多可用的RNG。也许其中一种会适合你。
https://stackoverflow.com/questions/53996085
复制相似问题