src/GameOfLife/Field.php
/**
     * Calculates the number of dead neighbor cells.
     *
     * @return int The number of dead neighbor cells
     */
Calculates the number of dead neighbor cells.
@return int The number of dead neighbor cells
Calculates the number of dead neighbor cells . @return int The number of dead neighbor cells
public function numberOfDeadNeighbors(): int
    {
        $neighbors = $this->parentBoard->getNeighborsOfField($this);
        $numberOfDeadNeighbors = 0;
        foreach ($neighbors as $neighbor)
        {
            if ($neighbor->isDead()) $numberOfDeadNeighbors++;
        }
        return $numberOfDeadNeighbors;
    }
public function numberOfDeadNeighbors ( ) : int { $ neighbors = $ this -> parentBoard -> getNeighborsOfField ( $ this ) ; $ numberOfDeadNeighbors = 0 ; foreach ( $ neighbors as $ neighbor ) { if ( $ neighbor -> isDead ( ) ) $ numberOfDeadNeighbors ++ ; } return $ numberOfDeadNeighbors ; }
Calculates the number of dead neighbor cells.
Calculates the number of dead neighbor cells .
/** @var Field[] $neighbors */