src/GameOfLife/GameLogic.php
/**
     * Calculates one game step for the entire board.
     *
     * @param Board $_board The board
     */
Calculates one game step for the entire board.
@param Board $_board The board
Calculates one game step for the entire board . @param Board $_board The board
public function calculateNextBoard(Board $_board)
    {
        $this->addToHistory($_board);
        $newFields = $_board->initializeEmptyBoard();
        foreach ($_board->fields() as $line)
        {
            foreach ($line as $field)
            {
                if ($field instanceof Field)
                {
                    $newState = $this->rule->calculateNewState($field);
                    $newFields[$field->y()][$field->x()]->setValue($newState);
                }
            }
        }
        $_board->setFields($newFields);
        $_board->setGameStep($_board->gameStep() + 1);
        $this->currentBoard = (string)$_board;
    }
public function calculateNextBoard ( Board $ _board ) { $ this -> addToHistory ( $ _board ) ; $ newFields = $ _board -> initializeEmptyBoard ( ) ; foreach ( $ _board -> fields ( ) as $ line ) { foreach ( $ line as $ field ) { if ( $ field instanceof Field ) { $ newState = $ this -> rule -> calculateNewState ( $ field ) ; $ newFields [ $ field -> y ( ) ] [ $ field -> x ( ) ] -> setValue ( $ newState ) ; } } } $ _board -> setFields ( $ newFields ) ; $ _board -> setGameStep ( $ _board -> gameStep ( ) + 1 ) ; $ this -> currentBoard = ( string ) $ _board ; }
Calculates one game step for the entire board.
Calculates one game step for the entire board .
/** @var Field[][] $newFields */