diff options
author | Justin Worthe <justin.worthe@entelect.co.za> | 2013-11-10 21:59:28 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@entelect.co.za> | 2013-11-10 21:59:28 +0200 |
commit | 75c1888aafcca04ba6240e60e1f55e868b47ac9f (patch) | |
tree | 38bce46b9d38bbfb1448a487c3f935b458fab9ec | |
parent | a0c4a6c45fc425e5957b3f838155e4a93c73c269 (diff) |
Fixed issue when trying to move left/right while in middle
Also made a change to the x distance for a bullet to be seen as 'my' bullet.
This is to compensate for the new issue of a tank moving in to the middle of
the field, messing up the original assumptions about how far apart they would
be.
-rw-r--r-- | Entelect.BattleCity.Challenge/AiAgent.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Entelect.BattleCity.Challenge/AiAgent.cs b/Entelect.BattleCity.Challenge/AiAgent.cs index 8b362ef..b02955d 100644 --- a/Entelect.BattleCity.Challenge/AiAgent.cs +++ b/Entelect.BattleCity.Challenge/AiAgent.cs @@ -51,15 +51,15 @@ namespace Entelect.BattleCity.Challenge var pastMidpoint = (Math.Abs(enemyBase.y-tank.y) < (board[0].Length / 2)); - if (stuckLastTurn && (tank.direction == ChallengeService.direction.UP || tank.direction == ChallengeService.direction.DOWN)) + if (stuckLastTurn && (tank.direction == ChallengeService.direction.UP || tank.direction == ChallengeService.direction.DOWN) && enemyBase.x != tank.x) { _targetX = tank.x + (pastMidpoint!=(tank.x > enemyBase.x) ? +1 : -1); } if (_checkForOpenPathToMiddle && !_headingToMiddle && tank.x != enemyBase.x) { - var pathToMiddleIsOpen = testPathToMiddleIsOpen(board, tank, enemyBase, true); - //TODO Disable driving over own base + var pathToMiddleIsOpen = testPathToMiddleIsOpen(board, tank, enemyBase); + if (pathToMiddleIsOpen) { Console.WriteLine("Path to middle is open, heading there now"); @@ -124,7 +124,7 @@ namespace Entelect.BattleCity.Challenge return move; } - private bool testPathToMiddleIsOpen(BoardCell[][] board, ChallengeService.unit tank, ChallengeService.@base enemyBase, bool allowGoThroughBase) + private bool testPathToMiddleIsOpen(BoardCell[][] board, ChallengeService.unit tank, ChallengeService.@base enemyBase) { var minY = tank.y - 2; var maxY = tank.y + 2; @@ -194,7 +194,7 @@ namespace Entelect.BattleCity.Challenge { foreach (var bullet in me.bullets) { - if (Math.Abs(bullet.x - tank.x) < board.Length / 4) + if (Math.Abs(bullet.x - tank.x) < board.Length / 6) { bulletInAir = true; } |