Jump to content
• ### What is your GameDev Story?

• Advertisement

# 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

Hello!
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:

http://img34.imageshack.us/img34/9097/picyk.jpg

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:

005
050
500

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:
212
302
221
113
etc etc

How to make this kind of tables?

#### Share this post

##### Share on other sites
Advertisement
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

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 13
• 9
• 15
• 14
• 46
• Advertisement
• ### Forum Statistics

• Total Topics
634059
• Total Posts
3015291
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!