Battle of Red Cliffs enemy positions help

I can't seem to find how to use enemyPositions in Battle of Red Cliffs. I know I'm not supposed to get help for a competition, but I can't seem to use enemyPosition even in various different methods:
#1. Says enemyPositions is not defined
game.log("enemyPositions", enemyPositions[0][0])
#2. I also tried using it with the choiceFunction same problem
def choiceFunction(state):
    p = enemyPositions[counter]
    game.log("pos:", p)
    type = myTeam[counter % 9][0]
    return type

#3. I then tried game.enemyPositions. At first,
# it seemed to work. but when I tried it, the game would freeze and say that code ran infinitely
game.log("enemyPositions: \n", game.enemyPositions[0])
#4. Same with the choice function
def choiceFunction(state):
    p = game.enemyPositions[counter]
    game.log("pos:", p)
    type = myTeam[counter % 9][0]
    return type

Is there any way of getting the enemyPositions while not getting timed out or an error. Thanks!

  • Edit: I also tried game.enemyPositions[0][0], and enemyPositions[0][0], but they also didn’t work.

Hi @PthonCC and welcome to the forum! :partying_face:

Where are you trying to put the positions in a variable?

Andrei

1 Like

This probably isn’t related but what is this?

@AnSeDra my intention was to put the list into the variable so that I can easily troubleshoot it, but the level would always error or it would give out undefined.

I did get that on Sunday, but it fixes after a while.

I was able to find how to use enemyPositions and enemyUnits. enemyPositions is in the state properties. The state needs to be from an event handler, as such:

def onThiefSpawn(state):
    game.log("Enemy Positions: ", state.enemyPositions) # here is how you should use it (not intended for game.log only)
    thief = state.target
    while True:
        enemy= thief.findNearestEnemy()
        if enemy:
            thief.attack(enemy)

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.