PHPackages                             jarrett/rockpaperscissorsspocklizard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jarrett/rockpaperscissorsspocklizard

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jarrett/rockpaperscissorsspocklizard
====================================

Based on a game created by Sam Kass and Karen Bryla and made popular by "Big Bang Theory"

1.1.4-stable(8y ago)030GPL-3.0HTML

Since Aug 29Pushed 8y agoCompare

[ Source](https://github.com/jarrettbarnett/RockPaperScissorsSpockLizard)[ Packagist](https://packagist.org/packages/jarrett/rockpaperscissorsspocklizard)[ RSS](/packages/jarrett-rockpaperscissorsspocklizard/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

[![Build Status](https://camo.githubusercontent.com/00997432405bdf3f36d25140cf9f5db8ae858d66016113bb6864d04ae13fc446/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6172726574746261726e6574742f526f636b506170657253636973736f727353706f636b4c697a6172642f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jarrettbarnett/RockPaperScissorsSpockLizard/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/9420c4caec39f4e14bdcfd683d69be3a44b1b1d3c9e59e51b39b70adda67763a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6172726574746261726e6574742f526f636b506170657253636973736f727353706f636b4c697a6172642f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jarrettbarnett/RockPaperScissorsSpockLizard/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/57c0bb02f8ebe6aae05ff1afe473b113eebcee91a6beef083f1411d12e31ec76/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6172726574746261726e6574742f526f636b506170657253636973736f727353706f636b4c697a6172642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jarrettbarnett/RockPaperScissorsSpockLizard/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/1ffa76815b820439d17866a7ba9f3beed9419ccfeb052c6796f8d02cffb91919/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f64373238303964312d653335372d343239322d386331382d3765303861353236666134322f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/d72809d1-e357-4292-8c18-7e08a526fa42)

RockPaperScissorsSpockLizard Game (in PHP)
==========================================

[](#rockpaperscissorsspocklizard-game-in-php)

A PHP class implementation of Rock Paper Scissors Spock Lizard as created by Sam Kass and Karen Bryla and popularized by "Big Bang Theory."

**Add as many players (or bots) as you want. Then play them all against each other at the same time!**

Packagist can be found here: [jarrett/rockpaperscissorsspocklizard](https://packagist.org/packages/jarrett/rockpaperscissorsspocklizard)

### Getting Started

[](#getting-started)

Install via composer:

```
composer install jarrett/rockpaperscissorsspocklizard

```

and require composer autoloader

```
require 'vendor/autoload.php';

```

### Basic Example:

[](#basic-example)

```
use Jarrett\RockPaperScissorsSpockLizard;
use Jarrett\RockPaperScissorsSpockLizard\Player;

// ...

$player = new Player();
$player->move('rock');

$bot = new Player();
$bot->isBot(true);

$game = new RockPaperScissorsSpockLizard();
$game->addPlayers($player, $bot)
     ->play();

$outcome = $game->getOutcomes();

```

### 2 Player Example:

[](#2-player-example)

```
use Jarrett\RockPaperScissorsSpockLizard;
use Jarrett\RockPaperScissorsSpockLizard\Player;

// ...

$player1 = new Player();
$player1->move('rock');

$player2 = new Player();
$player2->move('scissors');

$game = new RockpaperScissorsSpockLizard();
$game->setRounds(3)
     ->addPlayers($player1, $player2);
     ->play();

$outcome = $this->getOutcomes()

```

### 5 Player Example:

[](#5-player-example)

```
use Jarrett\RockPaperScissorsSpockLizard;
use Jarrett\RockPaperScissorsSpockLizard\Player;

// ...

// human
$player1 = new Player();
$player1->move('rock');

// human
$player2 = new Player();
$player2->move('paper');

// and 3 bots
$player3 = new Player();
$player4 = new Player();
$player5 = new Player();

$game = new RockpaperScissorsSpockLizard();
$game->addPlayers($player1, $player2, $player3, $player4, $player5)
     ->play();

// returns an array containing all wins, ties, and losses
$outcomes = $this->getOutcomes()

```

... or just throw the player instantiation directly into the addPlayers() method

```
$game = new RockpaperScissorsSpockLizard();
$game->addPlayers($player1, $player2, (new Player), (new Player), (new Player))
         ->play();

```

### Class Method Reference:

[](#class-method-reference)

Player( *string* $player\_name )
--------------------------------

[](#player-string-player_name-)

#### move( *string* $move)

[](#move-string-move)

Set your move

#### setName()

[](#setname)

Set player name. Can also be passed via the constructor. Generic "Player 1, 2, 3" will be used if name is empty.

#### getName()

[](#getname)

Get player name.

#### getMoveHistory()

[](#getmovehistory)

Get player's move history

#### getLastMove()

[](#getlastmove)

Get player's last move

RockPaperScissorsSpockLizard()
------------------------------

[](#rockpaperscissorsspocklizard)

#### play()

[](#play)

Play the round

#### restart()

[](#restart)

Restarts the game

#### setRounds( *string* $number, *bool* $lock = false)

[](#setrounds-string-number-bool-lock--false)

Set the number of rounds for this game. Default is 1 if not specified.

##### Parameters

[](#parameters)

###### $number *integer*

[](#number-integer)

- The maximum number of rounds before a winner is chosen

###### $lock *bool*

[](#lock-bool)

- If *true*, don't allow the number of rounds to change for this game
- If *false* (default), the maximum number of rounds can be changed during the game, even after a winner is determined.

#### getRounds()

[](#getrounds)

Returns all round results.

#### getOutcome()

[](#getoutcome)

Returns last round outcome.

#### addPlayer()

[](#addplayer)

Add player to the game.

#### addPlayers()

[](#addplayers)

Add multiple players to the game.

#### getPlayers()

[](#getplayers)

Return players for game.

#### getTotalPlayers()

[](#gettotalplayers)

Returns the number of players playing

#### getRoundWinner()

[](#getroundwinner)

Returns the player who won the last round.

#### getOutcomes()

[](#getoutcomes)

Returns the outcomes for all players.

#### getWinners()

[](#getwinners)

Returns the player who won the game.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

6

Last Release

3166d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/46b8e3bb62a286c1dbf3eabc771a23dc7b13fd3f5673ca275d1a1e1895cb002b?d=identicon)[jarrett](/maintainers/jarrett)

---

Top Contributors

[![jarrettbarnett](https://avatars.githubusercontent.com/u/265853?v=4)](https://github.com/jarrettbarnett "jarrettbarnett (49 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jarrett-rockpaperscissorsspocklizard/health.svg)

```
[![Health](https://phpackages.com/badges/jarrett-rockpaperscissorsspocklizard/health.svg)](https://phpackages.com/packages/jarrett-rockpaperscissorsspocklizard)
```

###  Alternatives

[letournel/path-finder

Path finder algorithm

142.0k](/packages/letournel-path-finder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
