# Test Environment Issue

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

## Recommended Posts

So I've been trying to learn AI using Programming Game AI by Example, online resources, etc. To help me along, I've set up a weird sort of test environment for the AI. I'll describe the (relevant) part that works:

The AI was originally given ten actions it could select from to perform under a budget of points. Each act had desirability calculated based on a set value reduced by a function of its point cost (and some other irrelevant things right now). Just to make sure the computer wasn't asleep on the job, the acts do not return proportionate amounts of desirability to their cost, and some are completely inverted. This step works fine (the computer really scrapes the bottom of the budget, as intended), no matter the budget of points.

I then had the AI calculate which acts it would perform if each act had to be repeated the same number of times, paying full cost and gaining full reward (desirability) for each repetition, while remaining under or tied with its given points budget for the entire spread. It does this just fine as well.

Now I want the AI to select the X number of repetitions on its own (within the bounds of 5 and a calculated maximum based on budget but capped at 300), returning the combination of acts and repetitions that returns the highest reward while still remaining under budget. While the program isn't so processor intensive that I couldn't do the individual tests for each possible number of repetitions to see which returns the highest results, that just seems plain sloppy. Am I wrong? I feel there has to be an equation I could boil at least part of this down to but repetitions affects costs affects desirability while watching the budget... I just can't wrap my head around it yet.

Any help would be greatly appreciated.

EDIT: Shoot, forgot a title somehow.

##### Share on other sites
You've just described the Knapsack problem. There's a lot to be said in this area, but that page is a good place to start.

##### Share on other sites
Yeah, that sounds like the problem. I'll give it a look, thanks!

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633689
• Total Posts
3013336
×