英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论