Advertisement Jump to content
Sign in to follow this  

Combinations and permuations

This topic is 3013 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a castle defense style game, where are 2 castles. Player castle and enemy castle. There are 3 different units to hire:
Swordsman, archer, horserider.

The units have points:
Swordsman(1), archer(2.5), horserider(3).

Player has made archer and swordsman. Total 3.5 points.
The AI have to understand the serious of the threat. The higher the points the bigger is the threat.

Now the AI have to make some soldiers to defend itself. So it have to hire soldiers whose total points are little bit higher than player points. It have to make the table and watch witch combination gives result where the points are a little bit higher than player's soldier points amount.

Here's the table that helps to understand:

The problem is that player can make up to 5 soldiers whose maximum points can be 15.

This means that AI have to also make a decision where it's points are the same this means that the table can be like this:


400 4 swordsmen
040 4 archers
004 4 horses
104 1 swordsmen, 4 horses
014 1 archer, 4 horses
401 4 swordsmen, 1 horse
410 4 swordsmen, 1 archer

the combinations can also be:
etc etc

How to make this kind of tables?

Share this post

Link to post
Share on other sites
Why are you making a table in the first place? Why can't you just use the values of the units, the total value of the army and use that value to make decisions?

You're making this harder that it should be.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!