• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #Actualalexzzzz

Posted 02 May 2013 - 04:03 PM

The easiest possible solution I came up with, is to automatically unroll any condition like "to have N items of something" into a set on conditions:
- to have N items,
- to have N-1 items,
...
- to have 1 item.

Will try it later to see if there are any pitfalls.

PS

It works!

When I get a condition like "to have 3 items"  I convert it to three conditions "to have 1 item", "to have 2 items", "to have 3 items". And when I get a sequence of actions "take 1 item" -> "take 1 item" -> "take 1 item" I convert it back to "take 3 items".

NUMBER OF RULES: 37

GOAL CONDITIONS:
1) Forest has 1 Fish
2) Forest has 2 Fish
3) Forest has 3 Fish

-----------------------------------------------------------------------------------------------
1 - | Cost 0 + penalty 3000000 = 3000000

2 - drop 1 Fish at Forest | Cost 1 + penalty 2200000 = 2200001

-----------------------------------------------------------------------------------------------
2 - drop 1 Fish at Forest | Cost 1 + penalty 2200000 = 220000

3 - goto Forest -> drop 1 Fish at Forest | Cost 51 + penalty 2100000 = 2100051
4 - catch 1 fish -> drop 1 Fish at Forest | Cost 2 + penalty 2200000 = 2200002
5 - drop 2 Fish at Forest | Cost 1 + penalty 1300000 = 1300001

-----------------------------------------------------------------------------------------------
5 - drop 2 Fish at Forest | Cost 1 + penalty 1300000 = 1300001

6 - goto Forest -> drop 2 Fish at Forest | Cost 51 + penalty 1200000 = 1200051
7 - catch 1 fish -> drop 2 Fish at Forest | Cost 2 + penalty 1300000 = 1300002
8 - drop 3 Fish at Forest | Cost 1 + penalty 400000 = 400001

-----------------------------------------------------------------------------------------------
8 - drop 3 Fish at Forest | Cost 1 + penalty 400000 = 400001

9 - goto Forest -> drop 3 Fish at Forest | Cost 51 + penalty 300000 = 300051
10 - catch 1 fish -> drop 3 Fish at Forest | Cost 2 + penalty 400000 = 400002

-----------------------------------------------------------------------------------------------
9 - goto Forest -> drop 3 Fish at Forest | Cost 51 + penalty 300000 = 300051

11 - catch 1 fish -> goto Forest -> drop 3 Fish at Forest | Cost 52 + penalty 266666 = 266718

-----------------------------------------------------------------------------------------------
11 - catch 1 fish -> goto Forest -> drop 3 Fish at Forest | Cost 52 + penalty 266666 = 266718

12 - goto Lake -> catch 1 fish -> goto Forest -> drop 3 Fish at Forest | Cost 152 + penalty 250000 = 250152
13 - craft 1 FishingRod -> catch 1 fish -> goto Forest -> drop 3 Fish at Forest | Cost 53 + penalty 275000 = 275053
14 - catch 2 fish -> goto Forest -> drop 3 Fish at Forest | Cost 52 + penalty 166666 = 166718

-----------------------------------------------------------------------------------------------
14 - catch 2 fish -> goto Forest -> drop 3 Fish at Forest | Cost 52 + penalty 166666 = 166718

15 - goto Lake -> catch 2 fish -> goto Forest -> drop 3 Fish at Forest | Cost 152 + penalty 150000 = 150152
16 - craft 1 FishingRod -> catch 2 fish -> goto Forest -> drop 3 Fish at Forest | Cost 53 + penalty 175000 = 175053
17 - catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 52 + penalty 66666 = 66718

-----------------------------------------------------------------------------------------------
17 - catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 52 + penalty 66666 = 66718

18 - goto Lake -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 152 + penalty 50000 = 50152
19 - craft 1 FishingRod -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 53 + penalty 75000 = 75053

-----------------------------------------------------------------------------------------------
18 - goto Lake -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 152 + penalty 50000 = 50152

20 - craft 1 FishingRod -> goto Lake -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 153 + penalty 20000 = 20153

-----------------------------------------------------------------------------------------------
20 - craft 1 FishingRod -> goto Lake -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 153 + penalty 20000 = 20153

21 - take 1 Wood at Forest -> craft 1 FishingRod -> goto Lake -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 154 + penalty 16666 = 16820

-----------------------------------------------------------------------------------------------
21 - take 1 Wood at Forest -> craft 1 FishingRod -> goto Lake -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 154 + penalty 16666 = 16820

22 - goto Forest -> take 1 Wood at Forest -> craft 1 FishingRod -> goto Lake -> catch 3 fish -> goto Forest -> drop 3 Fish at Forest | Cost 154 + penalty 0 = 154

FINAL PLAN:
1) goto Forest
2) take 1 Wood at Forest
3) craft 1 FishingRod
4) goto Lake
5) catch 3 fish
6) goto Forest
7) drop 3 Fish at Forest

The log shows regressive A* search iterations. The planner takes a plan with the lowest "cost+penalty" value from the sorted list, inserts some actions in the beginning and places it back to the list. The plan's "cost" is a sum of all its action costs, the "penalty" is a sum of penalties for all unsatisfied conditions (conditions that are closer to the end of the plan have higher penalties.)

### #1alexzzzz

Posted 29 April 2013 - 07:20 AM

The easiest possible solution I came up with, is to automatically unroll any condition like "to have N items of something" into a set on conditions:

- to have N items,

- to have N-1 items,

...

- to have 1 item.

Will try it later to see if there are any pitfalls.

PARTNERS