Skip to main content
deleted 1 character in body
Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345

I developed a turn-based game a while ago where I stood in front of the exact same problem.

You probably can not decide both move and action completely separate from each other, because the tile the unit moves to probably determines which potential targets are within the range of the actions it can perform. When the highest rated target is not within attack range from the highest rated tile, then moving to that tile might not be a very good decision after all.

I decided that my rating function needed to take both the action and the movement destination into account together. Specifically because I had a mechanic in the game where attacks could do more or less damage depending on the tile from which the attack was performed. But if you don't have anything like that, then it is probably possible for you to evaluate both the tile and the action with separate rating functions and then come to a final rating for each possible combination by adding or multiplying the results.

One problem I anticipated from this approach was the combinatiorialcombinatorial explosion. I had to check all reachable tiles, multiplied with all available actions, multiplied with all possible targets for these actions. I was worried that this could turn out to be a performance bottleneck. But it turned out it wasn't. The "thinking time" or the AI was still just a couple milliseconds per turn. And those were not noticeable for the players, because there was friction at that time anyway in form of a big "Enemy Turn!" banner being visible for a second.

If it would have been a problem, then I would have tacled this through trying to exclude destinations, actions and targets from the calculation where the game situation can already be used to determine that they probably don't make sense.

I developed a turn-based game a while ago where I stood in front of the exact same problem.

You probably can not decide both move and action completely separate from each other, because the tile the unit moves to probably determines which potential targets are within the range of the actions it can perform. When the highest rated target is not within attack range from the highest rated tile, then moving to that tile might not be a very good decision after all.

I decided that my rating function needed to take both the action and the movement destination into account together. Specifically because I had a mechanic in the game where attacks could do more or less damage depending on the tile from which the attack was performed. But if you don't have anything like that, then it is probably possible for you to evaluate both the tile and the action with separate rating functions and then come to a final rating for each possible combination by adding or multiplying the results.

One problem I anticipated from this approach was the combinatiorial explosion. I had to check all reachable tiles, multiplied with all available actions, multiplied with all possible targets for these actions. I was worried that this could turn out to be a performance bottleneck. But it turned out it wasn't. The "thinking time" or the AI was still just a couple milliseconds per turn. And those were not noticeable for the players, because there was friction at that time anyway in form of a big "Enemy Turn!" banner being visible for a second.

If it would have been a problem, then I would have tacled this through trying to exclude destinations, actions and targets from the calculation where the game situation can already be used to determine that they probably don't make sense.

I developed a turn-based game a while ago where I stood in front of the exact same problem.

You probably can not decide both move and action completely separate from each other, because the tile the unit moves to probably determines which potential targets are within the range of the actions it can perform. When the highest rated target is not within attack range from the highest rated tile, then moving to that tile might not be a very good decision after all.

I decided that my rating function needed to take both the action and the movement destination into account together. Specifically because I had a mechanic in the game where attacks could do more or less damage depending on the tile from which the attack was performed. But if you don't have anything like that, then it is probably possible for you to evaluate both the tile and the action with separate rating functions and then come to a final rating for each possible combination by adding or multiplying the results.

One problem I anticipated from this approach was the combinatorial explosion. I had to check all reachable tiles, multiplied with all available actions, multiplied with all possible targets for these actions. I was worried that this could turn out to be a performance bottleneck. But it turned out it wasn't. The "thinking time" or the AI was still just a couple milliseconds per turn. And those were not noticeable for the players, because there was friction at that time anyway in form of a big "Enemy Turn!" banner being visible for a second.

If it would have been a problem, then I would have tacled this through trying to exclude destinations, actions and targets from the calculation where the game situation can already be used to determine that they probably don't make sense.

Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345

I developed a turn-based game a while ago where I stood in front of the exact same problem.

You probably can not decide both move and action completely separate from each other, because the tile the unit moves to probably determines which potential targets are within the range of the actions it can perform. When the highest rated target is not within attack range from the highest rated tile, then moving to that tile might not be a very good decision after all.

I decided that my rating function needed to take both the action and the movement destination into account together. Specifically because I had a mechanic in the game where attacks could do more or less damage depending on the tile from which the attack was performed. But if you don't have anything like that, then it is probably possible for you to evaluate both the tile and the action with separate rating functions and then come to a final rating for each possible combination by adding or multiplying the results.

One problem I anticipated from this approach was the combinatiorial explosion. I had to check all reachable tiles, multiplied with all available actions, multiplied with all possible targets for these actions. I was worried that this could turn out to be a performance bottleneck. But it turned out it wasn't. The "thinking time" or the AI was still just a couple milliseconds per turn. And those were not noticeable for the players, because there was friction at that time anyway in form of a big "Enemy Turn!" banner being visible for a second.

If it would have been a problem, then I would have tacled this through trying to exclude destinations, actions and targets from the calculation where the game situation can already be used to determine that they probably don't make sense.