PHPackages                             alcalyn/awale - 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. alcalyn/awale

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

alcalyn/awale
=============

Awale game PHP implementation

1.0.0(10y ago)0555MITPHPPHP &gt;=5.3

Since Jan 16Pushed 10y agoCompare

[ Source](https://github.com/alcalyn/awale)[ Packagist](https://packagist.org/packages/alcalyn/awale)[ Docs](https://github.com/alcalyn/awale)[ RSS](/packages/alcalyn-awale/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Awale
=====

[](#awale)

This library provides a PHP implementation of the [Awale (or Oware) game](https://en.wikipedia.org/wiki/Oware).

Installation
------------

[](#installation)

### Download

[](#download)

Using Composer:

```
{
    "require": {
        "alcalyn/awale": "1.0.x"
    }
}
```

Update your composer.

```
composer update
```

Not using Composer ? [Install it directly](https://github.com/alcalyn/awale/archive/master.zip).

Usage
-----

[](#usage)

### Creating an instance

[](#creating-an-instance)

Create an instance of Awale, which is an instance of an Awale game state, with seeds.

```
use Alcalyn\Awale\Awale;

$awale = new Awale();

// Players start with 4 seeds in each container.
$awale->setSeedsPerContainer(4);

// The first player starts.
$awale->setCurrentPlayer(Awale::PLAYER_0);

// Needs to explicitly init the grid (containers seeds number, and attics).
$awale->initGrid();
```

Or to do it shorter:

```
use Alcalyn\Awale\Awale;

$awale = new Awale::createWithSeedsPerContainer(4);
```

### The grid

[](#the-grid)

The Awale grid represents the containers and attics.

```
// Retrieve the grid array from the Awale instance
$grid = $awale->getGrid();

print_r($grid);

/* Outputs:
Array
(
    [0] => Array                // Player 0, or player top.
        (
            [seeds] => Array
                (
                    [0] => 4    // Player 0 seeds, he has 4 seeds in each containers.
                    [1] => 4    // The first container is the top left container.
                    [2] => 4
                    [3] => 4
                    [4] => 4
                    [5] => 4    // The top right container.
                )

            [attic] => 0        // Player 0 has no seeds in his attic.
        )

    [1] => Array                // Player 1, or player bottom.
        (
            [seeds] => Array
                (
                    [0] => 4    // The bottom left container.
                    [1] => 4
                    [2] => 4
                    [3] => 4
                    [4] => 4
                    [5] => 4    // The bottom right container.
                )

            [attic] => 0        // No seeds in player 1 attic.
        )

)
*/
```

Or to get a graphical representation:

```
echo $awale;

/* Outputs:

Awale game instance.
     4  4  4  4  4  4
  0                    0
     4  4  4  4  4  4
seeds per container: 4
current player: PLAYER_0
last move: null

*/
```

### Play moves

[](#play-moves)

Once you have an instance of a game, you can play move.

```
// Top player plays his third container (from left)
$awale->play(Awale::PLAYER_0, 2);

// Bottom player plays his first container (from left)
$awale->play(Awale::PLAYER_1, 0);
```

The `play` method throws an `Alcalyn\Awale\Exception\AwaleException` on invalid move.

### Game usefull checks

[](#game-usefull-checks)

```
// Last played move
// An array with keys 'players' and 'move', example: {player:1, move:5}, Player 1 played his 5th container
$awale->getLastMove();

// Player's turn to play
$awale->getCurrentPlayer(); // Awale::PLAYER_0 or Awale::PLAYER_1

// Get amount of seeds needed to exceed, depending on seedsPerContainer
$awale->getSeedsNeededToWin(); // 24 if seedsPerContainer = 4

// Check is game is over (a player has more than 24 seeds, or game is looping, or player cannot feeds his opponent)
$awale->isGameOver(); // true or false

// Get winner when game is finished
$awale->getWinner(); // Awale::PLAYER_0 or Awale::PLAYER_1 or Awale::DRAW or null

// Get seeds number in a player attic
$awale->getScore(Awale::PLAYER_1);

// Whether a loop is detected (a same state of the game will appear again and again)
$awale->isGameLooping();
```

There is some other methods in the [Awale class](src/Awale.php).

Run unit tests
--------------

[](#run-unit-tests)

First, update your composer to get phpunit, then run:

```
vendor/bin/phpunit -c .
```

License
-------

[](#license)

This library is under the [MIT License](LICENSE).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3812d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17f0c4d65197a7aed6ecc8fdedd5a097c7238c9be19aca08c92c05d38fd8c29e?d=identicon)[alcalyn](/maintainers/alcalyn)

---

Top Contributors

[![alcalyn](https://avatars.githubusercontent.com/u/1588144?v=4)](https://github.com/alcalyn "alcalyn (5 commits)")

---

Tags

phpgameawaleoware

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alcalyn-awale/health.svg)

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21422.6k](/packages/imanghafoori-laravel-anypass)[irfa/php-gatcha

Simple Items Gatcha with PHP

352.4k](/packages/irfa-php-gatcha)

PHPackages © 2026

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