Files
basic-computer-games/77_Salvo/csharp/Targetting/ComputerShotSelector.cs
2023-05-18 19:27:56 +10:00

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);
}