Skip to content

Commit

Permalink
Document Chess\Eval\DefenseEval with comments (chesslablab#621)
Browse files Browse the repository at this point in the history
* Update DefenseEval.php

* Revert "Update DefenseEval.php"

This reverts commit c9a3812.

* Documented Chess\Eval\DefenseEval with comments

* Update DefenseEval.php

Comments convention.

---------

Co-authored-by: Jordi Bassagana <[email protected]>
  • Loading branch information
Neel-07 and programarivm authored Oct 2, 2024
1 parent 559e75d commit 87affec
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Eval/DefenseEval.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@
use Chess\Variant\AbstractPiece;
use Chess\Variant\Classical\PGN\AN\Piece;

/*
* Defense Evaluation
*
* This heuristic evaluates the defensive strength of each side by analyzing
* how the removal of attacking pieces would affect the opponent's protection.
* A higher score indicates a stronger defensive position.
*/
class DefenseEval extends AbstractEval implements
ElaborateEvalInterface,
ExplainEvalInterface
{
use ElaborateEvalTrait;
use ExplainEvalTrait;

/*
* The name of the heuristic.
*
* @var string
*/
const NAME = 'Defense';

/**
* @param \Chess\Variant\AbstractBoard $board
*/
public function __construct(AbstractBoard $board)
{
$this->board = $board;
Expand Down Expand Up @@ -62,6 +77,12 @@ public function __construct(AbstractBoard $board)
$this->explain($this->result);
}

/*
* Elaborate on the evaluation.
*
* @param \Chess\Variant\AbstractPiece $piece
* @param array $diffPhrases
*/
private function elaborate(AbstractPiece $piece, array $diffPhrases): void
{
$phrase = PiecePhrase::create($piece);
Expand Down

0 comments on commit 87affec

Please sign in to comment.