Difficulty with rulebooks producing variables

*** RESOLVED ***
Rulebook needed to be a stored action based rulebook rather than an action based rulebook.

OK, so I’m trying to build an AI that works like this:

  1. Examines all possible actions.

  2. Calculates a number for each possible action.

  3. Picks the action with the highest score.

  4. Does it.

Every turn when a soccer game scene is happening: if the AI turn is true: repeat with X running through visible people who are not the player: unless X is a team member listed in the roster of the home team or X is a team member listed in the roster of the away team: next; blank out the whole of Table of Action Considerations; follow the AI consideration rules for X; repeat through the Table of Action Considerations: let K be a number produced by (the AI evaluation rulebook) for (the possible action entry); now (the weight entry) is K; sort the table of action considerations in reverse weight order; choose row 1 from the table of action considerations; try the possible action entry; now the AI turn is false.

Which produces the error:

[code]Problem. You wrote ‘let K be a number produced by (the AI evaluation rulebook) for (the possible action entry)’ : but the ingredients in this phrase do not fit it, but I am confused enough by this that I can’t give a very helpful problem message. Sorry about that.

I was trying to match one of these phrases:

  1. (number - name of kind) produced by (the ai evaluation rulebook - values based rule producing values) for (the possible action entry - value)

  2. (number - name of kind) produced by (( the ai evaluation rulebook ) for ( the possible action entry ) - rule producing values)

This was what I found out:

number = a description of numbers

the AI evaluation rulebook = a rulebook producing numbers

the possible action entry = a table entry, holding a stored action

(the AI evaluation rulebook) for (the possible action entry) = something unrecognised
[/code]

Any ideas about what I’m doing wrong?

1 Like

I’m not familiar with ‘producing’ rulebooks, but try ‘let K be a number; now K is the number produced by…’.

Or just skip the variable entirely and do “now the weight entry is the number produced by the AI evaluation rulebook for the possible action entry;”

Yes, this is how I was doing it originally, but it resulted in the same error. But I’ll do it your way so you can see.

Every turn when a soccer game scene is happening: if the AI turn is true: repeat with X running through visible people who are not the player: unless X is a team member listed in the roster of the home team or X is a team member listed in the roster of the away team: next; blank out the whole of Table of Action Considerations; follow the AI consideration rules for X; repeat through the Table of Action Considerations: now (the weight entry) is the number produced by (the AI evaluation rulebook) for (the possible action entry); sort the table of action considerations in reverse weight order; choose row 1 from the table of action considerations; try the possible action entry; now the AI turn is false.

Which produces:

[code]Problem. You wrote ‘now (the weight entry) is the number produced by (the AI evaluation rulebook) for (the possible action entry)’ : but the ingredients in this phrase do not fit it, but I am confused enough by this that I can’t give a very helpful problem message. Sorry about that.

I was trying to match one of these phrases:

  1. (number - name of kind) produced by (the ai evaluation rulebook - values based rule producing values) for (the possible action entry - value)

  2. (number - name of kind) produced by (( the ai evaluation rulebook ) for ( the possible action entry ) - rule producing values)

This was what I found out:

number = a description of numbers

the AI evaluation rulebook = a rulebook producing numbers

the possible action entry = a table entry, holding a stored action

(the AI evaluation rulebook) for (the possible action entry) = something unrecognised
[/code]

I’ve always had a great deal of difficulty getting value-producing rulebooks to work, a shame knowing how powerful they are. Maybe I should just make a global variable and have it reset with each iteration?

Two things come to mind.

Is blanking out the action considerations table affecting the possible action entry?
Is the AI evaluation rulebook action-based?
Is using the term ‘rulebook’ instead of ‘rules’ in ‘the ai evaluation rulebook’ signifigant?

This minimal example works:

[code]“value-rulebook-test” by Anthony Casteel

The test rules are an object based rulebook producing a number.

the orb is a thing.
Test rule for the orb:
Rule succeeds with result 5.

Void is a room.
The orb is in the void.

Table of orbs
item result
The orb a number

Every turn:
Repeat through the table of orbs:
Now the result entry is the number produced by the test rules for the item entry;
Say “[the result entry]”.

[/code]

How are the AI evaluation rulebook defined?

Am I right in thinking that the AI consideration rules fill in the table? Why not make them calculate the weight directly?

And a tip from ATTACK: sort the table randomly before sorting by weight. Then if you have two rows with the same weight they’ll be chosen equally often.

This compiles just fine:

"test" by Ron Newcomb

There is a room.  Alice, Bob, Charlie, and Deanna are here.


Table of Action Considerations
possible action (a stored action)		weight (a number)
with 50 blank rows.

The AI evaluation rules are a stored action based rulebook producing a number.

The AI consideration rules are a person based rulebook.

Every turn:
	repeat with X running through visible people who are not the player:
		blank out the whole of Table of Action Considerations;
		follow the AI consideration rules for X;
		repeat through the Table of Action Considerations:
			now (the weight entry) is the number produced by (the AI evaluation rulebook) for (the possible action entry);
		sort the table of action considerations in reverse weight order;
		choose row 1 from the table of action considerations;
		try the possible action entry;
   

so I guess your real issue lies with a typo somewhere else?

Maybe you’ve defined the evaluation rules as being “action based” instead of “stored action based”? That causes the identical error you’ve listed above.

(annoying how the problem message generalizes it to “value based”)

Sorry, I was out of town for a few days, and I didn’t have time to check this thread.

Thank you. Yes, this seemed to be the problem. It still needs a little updating before it will be able to compile, but I’m not getting that error message anymore. Now I just need to update the rules.

Yes: it is compiling and working now. It is very satisfying to see an AI work, even as dumb as it is right now. When it’s at some sort of state of completion I’ll try posting a copy.