From 75c1888aafcca04ba6240e60e1f55e868b47ac9f Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 10 Nov 2013 21:59:28 +0200 Subject: 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. --- Entelect.BattleCity.Challenge/AiAgent.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Entelect.BattleCity.Challenge') 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; } -- cgit v1.2.3