From 1087ce4b2f6af352e9e4b83d07997efb63abb47d Mon Sep 17 00:00:00 2001 From: pierretienne Date: Mon, 8 Dec 2014 22:47:35 +0100 Subject: [PATCH] remise en prod retreat degat zone suite fausse alerte 10s sur les serveurs --- src/IA_Exemple__4393.lks | 64 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/src/IA_Exemple__4393.lks b/src/IA_Exemple__4393.lks index 6add17f..9985641 100644 --- a/src/IA_Exemple__4393.lks +++ b/src/IA_Exemple__4393.lks @@ -485,7 +485,7 @@ function retreat(){ //choper les couples item,enemy les plus dangereux var itemEnemyDangerIt_l = 0; var scoreTable_l = []; - var itemEnemyDanger_l = []; + var itemEnemyDistanceDanger_l = []; for(var enemy_l in ENEMIES_G){ if(isAlive(enemy_l)){ for(var item_l : var average_l in getItemsAttack(enemy_l)){ @@ -499,9 +499,11 @@ function retreat(){ && STUFFS_G[item_l][STUFF_COOLDOWN_G] > 1){ probaCooldownOK_l = 1/STUFFS_G[item_l][STUFF_COOLDOWN_G]; } - push(itemEnemyDanger_l, [item_l, enemy_l]); - scoreTable_l[itemEnemyDangerIt_l] = getNbAttackComplete(enemy_l, item_l) * probaCooldownOK_l * expectedDamage(enemy_l, item_l, ME_G, 0); - itemEnemyDangerIt_l++; + for(var distance_l = 0; distance_l <= STUFFS_G[item_l][STUFF_RADIUS_G]; distance_l++){ + push(itemEnemyDistanceDanger_l, [item_l, enemy_l, distance_l]); + scoreTable_l[itemEnemyDangerIt_l] = getNbAttackComplete(enemy_l, item_l) * probaCooldownOK_l * expectedDamage(enemy_l, item_l, ME_G, distance_l); + itemEnemyDangerIt_l++; + } } } } @@ -513,10 +515,10 @@ function retreat(){ retreatCells_l[cellIt_l] = 1; } var previousEnemy_l = -1; + var mapItemMapEnemyNoHiding_l = []; for(itemEnemyDangerIt_l : var score_l in scoreTable_l) { var nbInstructionBeginItemScore_l = getInstructionsCount(); - var item_l = itemEnemyDanger_l[itemEnemyDangerIt_l][0]; - var enemy_l = itemEnemyDanger_l[itemEnemyDangerIt_l][1]; + var enemy_l = itemEnemyDistanceDanger_l[itemEnemyDangerIt_l][1]; var cellsReachablebleEnemy_l = getReachableCellCloseToMe(LEEK_MOVEMENTS_G[enemy_l][TURN_G], LEEKS_VARIABLE_CARAC_G[enemy_l][TURN_G][CARAC_MP]); var estimatedComplexity_l = count(cellsReachablebleEnemy_l) * count(retreatCells_l) * COEF_ESTIMATD_COMPLEXITY_G; var securityInstructions_l = MIN_SECURITY_INSTRUCTION_G; @@ -527,18 +529,58 @@ function retreat(){ break; } + var item_l = itemEnemyDistanceDanger_l[itemEnemyDangerIt_l][0]; + if(mapItemMapEnemyNoHiding_l[item_l] !== null + && mapItemMapEnemyNoHiding_l[item_l][enemy_l] !== null){ + continue; + } + var distance_l = itemEnemyDistanceDanger_l[itemEnemyDangerIt_l][2]; var currentRetreatCells = retreatCells_l; - //on elimine les cellules dangereuse - for(var reachableCellMe_l : var pathMe_l in retreatCells_l){ - for(var reachableCellEnemy_l : var pathEnemy_l in cellsReachablebleEnemy_l){ - if(canShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, reachableCellMe_l, ME_G)){ - removeKey(currentRetreatCells, reachableCellMe_l); + //on elimine les cellules dangereuses + if(distance_l > 0) { + var outEdge_l = getDistantBorder(retreatCells_l, distance_l); + for(var hurtableCellMe_l : var cellsProducingIt_l in outEdge_l[distance_l - 1]){ + for(var reachableCellEnemy_l : var pathEnemy_l in cellsReachablebleEnemy_l){ + if(canShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, hurtableCellMe_l, ME_G)){ + var cellsToRemove_l = []; + push(cellsToRemove_l, hurtableCellMe_l); + for(var itDist_l = 0; itDist_l < distance_l; itDist_l++){ + var newCellsToRemove_l = []; + for(var itCellCurrentBorder in cellsToRemove_l){ + pushAll(newCellsToRemove_l, outEdge_l[distance_l - 1 - itDist_l][itCellCurrentBorder]); + } + cellsToRemove_l = newCellsToRemove_l; + } + for(var cellIt_l in cellsToRemove_l){ + removeKey(currentRetreatCells, cellIt_l); + } + break; + } + if(count(currentRetreatCells) == 0){ + break; + } + } + if(count(currentRetreatCells) == 0){ break; } } + }else{ + for(var reachableCellMe_l : var pathMe_l in retreatCells_l){ + for(var reachableCellEnemy_l : var pathEnemy_l in cellsReachablebleEnemy_l){ + if(canShootCellToCell(reachableCellEnemy_l, enemy_l, item_l, reachableCellMe_l, ME_G)){ + removeKey(currentRetreatCells, reachableCellMe_l); + break; + } + } + } } if(count(currentRetreatCells) > 0){ retreatCells_l = currentRetreatCells; + }else{ + if(mapItemMapEnemyNoHiding_l[item_l] === null){ + mapItemMapEnemyNoHiding_l[item_l] = []; + } + mapItemMapEnemyNoHiding_l[item_l][enemy_l] = 1; } var nbInstructions_l = getInstructionsCount() - nbInstructionBeginItemScore_l; -- 2.11.4.GIT