mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-27 05:03:27 -08:00
22 lines
780 B
C#
22 lines
780 B
C#
namespace Salvo.Targetting;
|
|
|
|
internal class ComputerShotSelector : ShotSelector
|
|
{
|
|
private readonly KnownHitsShotSelectionStrategy _knownHitsStrategy;
|
|
private readonly SearchPatternShotSelector _searchPatternShotSelector;
|
|
|
|
internal ComputerShotSelector(Grid source, Grid target, IRandom random)
|
|
: base(source, target)
|
|
{
|
|
_knownHitsStrategy = new KnownHitsShotSelectionStrategy(target);
|
|
_searchPatternShotSelector = new SearchPatternShotSelector(source, target, random);
|
|
}
|
|
|
|
internal override IEnumerable<Position> GetShots()
|
|
{
|
|
return _knownHitsStrategy.GetShots(NumberOfShots) ?? _searchPatternShotSelector.GetShots();
|
|
}
|
|
|
|
internal void RecordHit(Ship ship, int turn) => _knownHitsStrategy.RecordHit(ship, turn);
|
|
}
|