PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Ogbemudia Osayawe   Conway's Game of Life PHP   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Conway's Game of Life PHP
Implementation of the game of life simulation
Author: By
Last change:
Date: 10 months ago
Size: 948 bytes
 

Contents

Class file image Download
<?php declare(strict_types=1);

use
App\GameOfLife\Board;
use
App\GameOfLife\Config\GameConfig;
use
App\GameOfLife\Factory\GridFactory;
use
App\GameOfLife\GameOfLife;
use
App\GameOfLife\Config\LiveCell;
use
App\GameOfLife\NextGenerationIgnoredEdge;
use
App\GameOfLife\NextGenerationWrapAroundEdge;

require_once
__DIR__ . '/vendor/autoload.php';

/*$liveCells = [
    new LiveCell(1, 4),
    new LiveCell(2, 3),
    new LiveCell(2, 4),
];
*/
//4, 8

//$ignoredEdgesAlgorithm = new NextGenerationIgnoredEdge();

$liveCells = [
    new
LiveCell(0, 2),
    new
LiveCell(1, 3),
    new
LiveCell(2, 1),
    new
LiveCell(2, 2),
    new
LiveCell(2, 3),
];

$wrapAroundEdgesAlgorithm = new NextGenerationWrapAroundEdge();
$board = new Board(new GridFactory(...$liveCells), 5, 6);

$iterations = 5;
$gameConfig = new GameConfig(
   
$board,
   
$wrapAroundEdgesAlgorithm,
   
$iterations
);

(new
GameOfLife($gameConfig))->start();