随机选择 Daml

huangapple go评论48阅读模式
英文:

Random selection Daml

问题

有人知道如何在Daml中模拟随机选择吗?我理解在Daml中不能进行非确定性选择(我应该调用外部Oracle并请求一个索引),但出于测试目的,我应该能够在软件中模拟随机选择。

这样正确吗?有人可以帮忙吗?
我找不到任何像“choose”、“shuffle”或其他相关函数。

有人可以指导我吗?
非常感谢任何帮助!

英文:

Does anyone know how to simulate a random selection in Daml? My understanding is that I cannot make non-deterministic choices in Daml (I should call an external Oracle and ask for an index), but for testing purposes I should be able to simulate a random selection within the software.

Is that correct? Could someone please help?
I cannot find any function such as "choose" "shuffle" or any other related function.

Could someone point me in the right direction please?

Any help would be very much appreciated!!!

答案1

得分: 2

根据您提到的,解释 Daml 的结果需要是确定性的。Daml 应该对游戏的规则进行编码(这需要为所有玩家产生确定性结果),而使用 Ledger API 的代码定义了所使用的策略,这可能会引入一定程度的随机性。如果您想在工作流程中引入一些随机性,您需要将其作为与非账本组件交互的一部分。

英文:

As you mentioned, the outcome of interpreting Daml need to be deterministic. Daml is supposed to encode the rules of the game (which need to yield deterministic results for all the players), while code using the Ledger API defines the strategy used, which can introduce an element of randomness to it. If you want to introduce some level of randomness to your workflow, you will need to make it part of the interaction with an off-ledger component.

huangapple
  • 本文由 发表于 2023年5月17日 17:58:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定