Created
March 29, 2017 16:28
Star
You must be signed in to star a gist
Une IA pour arriver sur l'ennemi en même temps que ses bulbes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chip = CHIP_ROCKY_BULB; | |
if (getWeapon()==null) setWeapon(WEAPON_DESTROYER); | |
var enemy = getNearestEnemy(); | |
var bulbe = unDeMesBulbes(); | |
if (jeSuisSuffisammentLoinDe(enemy) and bulbe != null) { | |
avanceVersSansTropTEloignerDe(enemy, bulbe); | |
} else { | |
moveToward(enemy); | |
} | |
summon(chip, aPorteDePuceVers(chip,enemy), fonce); | |
function fonce() { | |
moveToward(getNearestEnemy()); | |
} | |
function jeSuisSuffisammentLoinDe(poireau) { | |
return getPathLength(getCell(), getCell(poireau)) > 10; | |
} | |
function unDeMesBulbes() { | |
for (var allie in getAliveAllies()) { | |
if (isSummon(allie) and getSummoner(allie)==getLeek()) return allie; | |
} | |
} | |
function avanceVersSansTropTEloignerDe(enemy, bulbe) { | |
debug("j'avance mais pas trop"); | |
var ecartIdeal = 3; | |
var distanceEntreEnnemiEtMoi = getPathLength(getCell(enemy), getCell()); | |
var distanceEntreEnnemiEtBulbe = getPathLength(getCell(enemy), getCell(bulbe)); | |
var ecart = distanceEntreEnnemiEtMoi - distanceEntreEnnemiEtBulbe; | |
if (ecart > ecartIdeal) | |
moveTowardCell(getCell(enemy)); | |
} | |
function aPorteDePuceVers(chip, enemy) { | |
var candidats = getCellsToUseChip(chip, getLeek()); | |
var laPlusProche = pop(candidats); | |
var cible = getCell(enemy); | |
var plusPetiteDistance = getCellDistance(cible, laPlusProche);; | |
for (var cellule in candidats) { | |
var distance = getCellDistance(cible, cellule); | |
if (distance < plusPetiteDistance) { | |
plusPetiteDistance = distance; | |
laPlusProche = cellule; | |
} | |
} | |
return laPlusProche; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment