Skip to content

feat: rock-paper-scissors#14

Open
dckc wants to merge 13 commits into
mainfrom
dc-fun-games
Open

feat: rock-paper-scissors#14
dckc wants to merge 13 commits into
mainfrom
dc-fun-games

Conversation

@dckc

@dckc dckc commented Apr 25, 2024

Copy link
Copy Markdown
Contributor

goal:

playground/packages/fun-games$ endo purge --force

playground/packages/fun-games$ endo make src/rock-paper-scissors.js -n rps
Starting Endo daemon...
Object [Alleged: RockPaperScissors] {}

playground/packages/fun-games$ endo mkhost bob bob-agent
Object [Alleged: EndoHost] {}

playground/packages/fun-games$ endo eval 'E(rps).playAgainst(bob)' bob rps

but I get:

CapTP cli exception: (RemoteTypeError(error:captp:Endo#20001)#1)
RemoteTypeError(error:captp:Endo#20001)#1: target has no method "accept", has ["__getInterfaceGuard__","__getMethodNames__","open","receive"]

  at decodeErrorCommon (packages/marshal/src/marshal.js:303:24)
  at decodeErrorFromCapData (packages/marshal/src/marshal.js:331:14)
  at decodeFromCapData (packages/marshal/src/encodeToCapData.js:384:27)
  at fromCapData (packages/marshal/src/marshal.js:393:23)
  at CTP_RETURN (packages/captp/src/captp.js:693:24)
  at dispatch (packages/captp/src/captp.js:772:7)
  at packages/daemon/src/connection.js:36:7

(RemoteTypeError(error:captp:Endo#20001)#1)

@dckc

dckc commented Apr 26, 2024

Copy link
Copy Markdown
Contributor Author

simplified design: gameServer.attack(move) => { defend(move) => result }

based on discussion with @kriskowal

playground/packages/fun-games$ endo make src/rock-paper-scissors.js -n p1
Object [Alleged: RockPaperScissors] {}

playground/packages/fun-games$ endo eval "E(p1).attack('rock')" p1 -n p2
Object [Alleged: Defender] {}

playground/packages/fun-games$ endo eval "E(p2).defend('paper')" p2
{ why: 'paper covers rock', winner: 2 }
  • interface names are kinda goofy

added some unit tests too:

$ yarn test
yarn run v1.22.21
$ ava

  ✔ Rock Paper Scissors: 1 game
    ℹ {
        why: 'paper covers rock',
        winner: 2,
      }
  ✔ only 3 choices allowed
  ✔ attacker cannot attack again
  ─

  3 tests passed

@dckc dckc requested a review from kriskowal April 26, 2024 20:19
@dckc dckc changed the title WIP: rock-scissors-paper feat: rock-paper-scissors Apr 26, 2024
kriscendobot pushed a commit to endojs/endo-but-for-bots that referenced this pull request May 17, 2026
A small teaching demo: a two-player Rock Paper Scissors game packaged
as an Endo daemon plugin, with a pure scoring core and an exo-wrapped
attacker/defender capability pair. Adapted from the fun-games package
in endojs/playground#14.

The pure scoring rules live in `src/score.js` and the daemon-loadable
plugin lives in `src/rock-paper-scissors.js`. Tests exercise both
layers: every pair-and-outcome of the scoring function, plus the exo
boundary (pattern-guard rejections, one-shot attack discipline,
parallel games, late-bound getResult).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant