LogoLogo
1.0.0
  • Home
  • Install
  • Docs
  • Contribute
  • Journey
  • Welcome
  • The Varphi Language Standard
    • Welcome
    • State Names
    • Tallies and Blanks
    • Head Directions
    • Lines
    • Comments
    • Varphi Programs
    • Addressing Ambiguities
  • Writing Varphi Programs
    • Your First Varphi Program
    • Running Varphi Programs
    • Debugging Varphi Programs
    • The Varphi VS Code Extension
    • Good Practices
    • More Examples
      • Addition By One
      • Add Two Numbers
      • Multiplication By Two
      • Rock, Paper, Scissors
      • Coin Flip
  • Turing Machine Theory
    • The Unary Number System
    • Turing Machine Tapes
    • Turing Machine Heads
    • Turing Machine States
    • Turing Machines
    • Nondeterministic Turing Machines
Powered by GitBook
LogoLogo

© 2025 Hassan El-Sheikha

On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Writing Varphi Programs
  2. More Examples

Rock, Paper, Scissors

Below is a program which determines the winner of a game of Rock, Paper, Scissors between two players.

The machine accepts an input tape containing two contiguous blocks of tallies separated by a blank tape cell, representing the moves of the two players. The first block of tallies (i.e., to the left) will represent the move of the first player, and the second block will represent the move of the second player.

Each contiguous block for a player's move can look like the following:

  • 1 , if the move is Rock

  • 11 , if the move is Paper

  • 111 , if the move is Scissors

For example, the input tape 110111 would represent that the first player played Paper, and the second player played Scissors.

The output tape will be a contiguous block of tallies representing the result of the game. This output tape will take on one of the following forms:

  • 1 , if the result was a tie

  • 11 , if the first player won

  • 111 , if the second player won

qUnknown 1 qRock 0 R
qRock 1 qPaper 0 R
qPaper 1 qScissors 0 R

qRock 0 qRockUnknown 0 R
qPaper 0 qPaperUnknown 0 R
qScissors 0 qScissorsUnknown 0 R

qRockUnknown 1 qRockRock 0 R
qPaperUnknown 1 qPaperRock 0 R
qScissorsUnknown 1 qScissorsRock 0 R

qRockRock 1 qRockPaper 0 R
qRockPaper 1 qRockScissors 0 R

qPaperRock 1 qPaperPaper 0 R
qPaperPaper 1 qPaperScissors 0 R

qScissorsRock 1 qScissorsPaper 0 R
qScissorsPaper 1 qScissorsScissors 0 R

qRockRock 0 qTie 0 R
qRockPaper 0 qPlayer2Won 0 R
qRockScissors 0 qPlayer1Won 0 R
qPaperRock 0 qPlayer1Won 0 R
qPaperPaper 0 qTie 0 R
qPaperScissors 0 qPlayer2Won 0 R
qScissorsRock 0 qPlayer2Won 0 R
qScissorsPaper 0 qPlayer1Won 0 R
qScissorsScissors 0 qTie 0 R

qTie 0 qWrite1 0 R
qPlayer1Won 0 qWrite2 0 R
qPlayer2Won 0 qWrite3 0 R

qWrite1 0 qHalt 1 R
qWrite2 0 qWrite1 1 R
qWrite3 0 qWrite2 1 R

PreviousMultiplication By TwoNextCoin Flip

Last updated 4 months ago

Was this helpful?