InfluxOW/TicTacToe

View on GitHub
src/AI/Easy.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace App\AI;

use App\Board;
use App\Enums\Filler;

class Easy implements AI
{
    public function move(Board $board, Filler $filler): void
    {
        foreach ($board->show() as $row => $cols) {
            foreach ($cols as $col => $_) {
                if ($board->isCellEmpty($row, $col)) {
                    $board->fill($row, $col, $filler);
                    return;
                }
            }
        }
    }
}