public override string ToString() { var targetCoordString = targetCoord.HasValue ? $", goto: {FastCoord.ToCoord(targetCoord.Value)}" : ""; var targetBarrelIdString = targetBarrelId.HasValue ? $", barrel: {targetBarrelId.Value}" : ""; var fireToCoordString = fireToCoord.HasValue ? $", fireTo: {FastCoord.ToCoord(fireToCoord.Value)}" : ""; var explicitCommandString = explicitCommand.HasValue ? $", explicit: {explicitCommand.Value}" : ""; return($"{role}{targetCoordString}{targetBarrelIdString}{fireToCoordString}{explicitCommandString}"); }
public void NearMap_GoIn_ReturnsValidFastCoord(int x, int y, int orientation) { var coord = new Coord(x, y); var fastCoord = FastCoord.Create(coord); var neighbor = FastCoord.Neighbor(fastCoord, orientation); var actual = FastCoord.ToCoord(neighbor); actual.Should().Be(coord.Neighbor(orientation)); }
public void FarFromMap_ReturnsValidFastCoord(int x, int y) { var coord = new Coord(x, y); var fastCoord = FastCoord.Create(coord); fastCoord.Should().Be(-1); var actual = FastCoord.ToCoord(fastCoord); actual.Should().Be(new Coord(-1000, -1000)); }
public void InsideMap_ReturnsValidFastCoord() { for (int x = 0; x < Constants.MAP_WIDTH; x++) { for (int y = 0; y < Constants.MAP_HEIGHT; y++) { var coord = new Coord(x, y); var fastCoord = FastCoord.Create(coord); var actual = FastCoord.ToCoord(fastCoord); actual.Should().Be(coord); } } }
public void InsideMap_ReturnsValidFastCoord(int orientation) { for (int x = 0; x < Constants.MAP_WIDTH; x++) { for (int y = 0; y < Constants.MAP_HEIGHT; y++) { var coord = new Coord(x, y); var fastCoord = FastCoord.Create(coord); var neighbor = FastCoord.Neighbor(fastCoord, orientation); var actual = FastCoord.ToCoord(neighbor); actual.Should().Be(coord.Neighbor(orientation)); } } }
public void Stern_ReturnsValidCoord() { for (int x = 0; x < Constants.MAP_WIDTH; x++) { for (int y = 0; y < Constants.MAP_HEIGHT; y++) { for (int speed = 0; speed <= Constants.MAX_SHIP_SPEED; speed++) { for (int orientation = 0; orientation < 6; orientation++) { var shipPosition = new ShipPosition(new Coord(x, y), orientation, speed); var fastShipPosition = FastShipPosition.Create(shipPosition); FastCoord.ToCoord(FastShipPosition.Stern(fastShipPosition)).Should().Be(shipPosition.stern, shipPosition.ToString()); } } } } }
public void NearMap_ReturnsValidFastCoord() { for (int x = -1; x < Constants.MAP_WIDTH + 1; x++) { { var coord = new Coord(x, -1); var fastCoord = FastCoord.Create(coord); fastCoord.Should().BeGreaterOrEqualTo(0); var actual = FastCoord.ToCoord(fastCoord); actual.Should().Be(coord); } { var coord = new Coord(x, Constants.MAP_HEIGHT); var fastCoord = FastCoord.Create(coord); fastCoord.Should().BeGreaterOrEqualTo(0); var actual = FastCoord.ToCoord(fastCoord); actual.Should().Be(coord); } } for (int y = -1; y < Constants.MAP_HEIGHT + 1; y++) { { var coord = new Coord(-1, y); var fastCoord = FastCoord.Create(coord); fastCoord.Should().BeGreaterOrEqualTo(0); var actual = FastCoord.ToCoord(fastCoord); actual.Should().Be(coord); } { var coord = new Coord(Constants.MAP_WIDTH, y); var fastCoord = FastCoord.Create(coord); fastCoord.Should().BeGreaterOrEqualTo(0); var actual = FastCoord.ToCoord(fastCoord); actual.Should().Be(coord); } } }
public override string ToString() { return($"enemiesMov: {string.Join("; ", enemyShipsMovedPositions.Select(FastShipPosition.ToShipPosition))} | " + $"enemiesFin: {string.Join("; ", enemyShipsFinalPositions.Select(FastShipPosition.ToShipPosition))} | " + $"myships: {string.Join("; ", myShipsPositions.Select(FastShipPosition.ToShipPosition))} | " + $"cannonballs: {string.Join("; ", cannonballCoordsMap.Select((b, i) => new { b, i }).Where(x => x.b).Select(x => FastCoord.ToCoord(x.i)))} | " + $"mines: {string.Join("; ", mineDamageCoordMap.Select((d, i) => new { d, i }).Where(x => x.d != 0).Select(x => FastCoord.ToCoord(x.i)))} | " + $"nearMines: {string.Join("; ", nearMineDamageCoordMap.Select((d, i) => new { d, i }).Where(x => x.d != 0).Select(x => FastCoord.ToCoord(x.i)))}"); }
public override string ToString() { return($"{nameof(ftarget)}: {FastCoord.ToCoord(ftarget)}, {nameof(rum)}: {rum}, {nameof(turns)}: {turns}, {nameof(TargetType)}: {TargetType}"); }