# Multiple Actors Tutorial

**URL:** <https://forum.dfinity.org/t/multiple-actors-tutorial/1270>\
**Category:** Getting Started\
**Created:** [September 16, 2020, 12:39pm UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270 "2020-09-16T12:39:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carbosix](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/carbosix/32/23577_2.png) [@Carbosix](https://forum.dfinity.org/u/Carbosix)\
**Post date:** [September 16, 2020, 12:39pm UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270/1 "2020-09-16T12:39:27Z")

</div>

Hi, I’ve been going through the SDK tutorials again, in the [Multiple Actors](https://sdk.dfinity.org/docs/developers-guide/tutorials/multiple-actors.html) tut, there is a hard coded result in the Rock/Paper/Scissors canister when calling…

- dfx canister call rock\_paper\_scissors contest  
How would I call the battle\_round to get a random result? (I’ve tried editing to main.mo bu had no luck)

---

<div class="post-metadata">

**Author:** ![morrolan](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@morrolan](https://forum.dfinity.org/u/morrolan)\
**Post date:** [September 16, 2020, 2:32pm UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270/2 "2020-09-16T14:32:02Z")

</div>

The `battle_round` function calls the `alice` and `bob` functions, which determine what Alice and Bob will play respectively. Currently these two functions return hard-coded results, with Alice always playing paper, Bob always playing rock. It’s the Hollywood principle - “You don’t call us, we’ll call you” 😛

To turn this into an actual game, you’d have to edit these two methods, such that the choice for each round would be based on eg what a real-life player picks, or be based on the previous moves of the other player if you want to implement a computer opponent.

Chances are that, for your first draft, the `battle_rounds` function can remain untouched. All it does is call `alice` and `bob`, and grant points according to who won the current round.

---

<div class="post-metadata">

**Author:** ![pie-silo](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@pie-silo](https://forum.dfinity.org/u/pie-silo)\
**Post date:** [September 21, 2020, 6:02pm UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270/3 "2020-09-21T18:02:01Z")

</div>

Is there a way to generate a random number so that their decisions are more interesting?

---

<div class="post-metadata">

**Author:** ![morrolan](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@morrolan](https://forum.dfinity.org/u/morrolan)\
**Post date:** [September 21, 2020, 7:51pm UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270/4 "2020-09-21T19:51:31Z")

</div>

Kind of, but it won’t be all too straight-forward.  
Motoko doesn’t provide access to randomness as of now. Meaning if you want randomness you’ll need to generate it client-side (ie in JS), or implement a PRNG of your own. Both are suitable for some basic PoC game, but take some work.

---

<div class="post-metadata">

**Author:** ![pie-silo](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@pie-silo](https://forum.dfinity.org/u/pie-silo)\
**Post date:** [September 21, 2020, 9:25pm UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270/5 "2020-09-21T21:25:59Z")

</div>

Will that be added in future? Or is it an inherent constraint due to an architectural decision that the methods must be deterministic?

---

<div class="post-metadata">

**Author:** ![pie-silo](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@pie-silo](https://forum.dfinity.org/u/pie-silo)\
**Post date:** [September 22, 2020, 12:42am UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270/6 "2020-09-22T00:42:11Z")

</div>

I found [https://github.com/stanleygjones/hero-app-generator/blob/master/src/hackathon/Utils/Math.mo](https://github.com/stanleygjones/hero-app-generator/blob/master/src/hackathon/Utils/Math.mo) but it starts from a fixed seed and so always generates the same numbers.

---

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [September 22, 2020, 6:16am UTC](https://forum.dfinity.org/t/multiple-actors-tutorial/1270/7 "2020-09-22T06:16:36Z")

</div>

In the future it should be possible to derive randomness from dfinitys random beacon natively.
