intfiction.org

The Interactive Fiction Community Forum
It is currently Sun May 26, 2013 4:41 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Apr 16, 2012 1:13 am 
Offline

Joined: Wed Oct 13, 2010 1:42 am
Posts: 343
TL;DR: Unable to do text comparisons with the topic understood of an action because of the type conflict between text and snippets.

While skills are often used implicitly, as in the attacking example from my last thread, a proper skill system should allow the player to use them explicitly, so there needs to be a "use skill" verb, which is apparently very difficult. The basic system:

Code:
The school is a room.

A person has a number called the Strength.  The strength of a person is usually 3.
A person has a number called the Agility.  The agility of a person is usually 4.
A person has a number called the Perception.  The perception of a person is usually 5.
A person has a number called the Stamina.  The stamina of a person is usually 2.

Table of Skill Difficulties
Skill   Ability   Difficulty
"Brawl"   "Strength"   4
"Dodge"   "Agility"   4
"Climb"   "Strength"   5
"Spot"   "Perception"   6
"Swim"   "Stamina"   6

To decide which number is the score of (T - some text) for (P - a person):
   if T is "Strength", decide on the strength of P;
   if T is "Agility", decide on the agility of P;
   if T is "Perception", decide on the perception of P;
   if T is "Stamina", decide on the stamina of P;
   decide on 0.
   
A person has a table name called the skill table.  The skill table of a person is usually the Table of Generic Skills.

Table of Generic Skills
Skill   Level
"Dodge"   1
"Brawl"   1


And a skill for using:

Code:
Using is an action applying to one topic.
Understand "use [text]" as using.


The trouble begins with the check rules. We want to be able to check if the topic understood is on the skill list at all, if it's on the player's skill list specifically, and it would be nice to have arbitrary rules, too, but we can't do any of those because the topic understood is a snippet, not a text, and can't be directly compared to texts:

Code:
Check using:
   if the topic understood is not a skill listed in the table of skill difficulties, say "While I'm sure [the topic understood] is a fascinating field of study, it is not featured in this game." instead;
   if the topic understood is not a skill listed in the skill table of the player, say "In your youthful foolishness, you failed to pay attention during [the topic understood] class." instead;
   if the topic understood is "Toaster Repair", say "What, are you expecting to find broken toasters everywhere you go?" instead.


The first two check rules can be fixed by changing the Skill columns of the tables to Topic columns:

Code:
Table of Skill Difficulties
Topic   Ability   Difficulty
"Brawl"   "Strength"   4
"Dodge"   "Agility"   4
"Climb"   "Strength"   5
"Spot"   "Perception"   6
"Swim"   "Stamina"   6

A person has a table name called the skill table.  The skill table of a person is usually the Table of Generic Skills.

Table of Generic Skills
Topic   Level
"Dodge"   1
"Brawl"   1

Using is an action applying to one topic.
Understand "use [text]" as using.

Check using:
   if the topic understood is not a topic listed in the table of skill difficulties, say "While I'm sure [the topic understood] is a fascinating field of study, it is not featured in this game." instead;
   if the topic understood is not a topic listed in the skill table of the player, say "In your youthful foolishness, you failed to pay attention during [the topic understood] class." instead.


But we've still lost the toaster rule. More importantly, it's just kicking the problem down the road: since the table columns are now snippets instead of text, now all the other rules that compare text to the skill tables won't work, such as this:

Code:
To decide if (P - a person) has mastered (T - some text):
   if there is a skill of T in the skill table of P, decide yes;
   decide no.
   
When play begins:
   if the player has mastered "Dodge", say "Dodging!";
   if the player has mastered "Climb", say "Climbing!"


(Changing "a skill of T" to "a topic of T" makes it compile, but it still won't work.) Solutions?


Top
 Profile Send private message  
 
PostPosted: Mon Apr 16, 2012 1:40 am 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 2087
After last thread, is there a reason why you can't drop the quotes and use a kind of value? You really are working against the grain, trying to use strings as internal value keys.

You've already got the decide phrase with one line per property, which is the thing you need to make the kind-of-value viable.


Top
 Profile Send private message  
 
PostPosted: Mon Apr 16, 2012 8:34 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
If you're trying to get the text comparsion to work, then this should work.

Code:
"Test"

The School is A Room.

A person has a number called the Strength.  The strength of a person is usually 3.
A person has a number called the Agility.  The agility of a person is usually 4.
A person has a number called the Perception.  The perception of a person is usually 5.
A person has a number called the Stamina.  The stamina of a person is usually 2.

Table of Skill Difficulties
Skill   Ability   Difficulty
"Brawl"   "Strength"   4
"Dodge"   "Agility"   4
"Climb"   "Strength"   5
"Spot"   "Perception"   6
"Swim"   "Stamina"   6

To decide which number is the score of (T - some text) for (P - a person):
   if T is "Strength", decide on the strength of P;
   if T is "Agility", decide on the agility of P;
   if T is "Perception", decide on the perception of P;
   if T is "Stamina", decide on the stamina of P;
   decide on 0.
   
A person has a table name called the skill table.  The skill table of a person is usually the Table of Generic Skills.

Table of Generic Skills
Skill   Level
"Dodge"   1
"Brawl"   1

Using is an action applying to one topic. Understand "Use [text]" as using.

Temporary is a truth state that varies.

Check using:
if the topic understood exactly matches the text "Toaster Repair", case insensitively begin;
say "What, are you expecting to find broken toasters everywhere you go?" instead;
end if;
now temporary is false;
repeat through the table of skill difficulties begin;
if the topic understood exactly matches the text skill entry, case insensitively begin;
now temporary is true;
end if;
end repeat;
if temporary is false, say "While I'm sure [the topic understood] is a fascinating field of study, it is not featured in this game." instead;
now temporary is false;
repeat through the skill table of the player begin;
if the topic understood exactly matches the text skill entry, case insensitively begin;
now temporary is true;
end if;
end repeat;
if temporary is false, say "In your youthful foolishness, you failed to pay attention during [the topic understood] class." instead.

Report using:
say "This succeeds.".

Test me with "use toaster repair / use speed / use swim / use spot / use climb / use dodge / use brawl".


In general, comparing any text using "if A is B", even if it is in a table, doesn't work nicely. The best way is to compare them using "if A matches the text B" and "if A exactly matches the text B".

However, I believe zarf makes a good point. It's better to use kinds of value rather than strings.

_________________
"Will you stop breaking the fourth wall? It's costing me an absolute fortune to replace it!"


Top
 Profile Send private message  
 
PostPosted: Mon Apr 16, 2012 10:50 am 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 2087
Quote:
In general, comparing any text using "if A is B", even if it is in a table, doesn't work nicely.


There are less-than-general cases where it *does* work nicely. (If there are no indexed texts, topics, or snippets in sight, the texts do not have []-substitutions, and the texts are not derived from the player's input, then the comparison is both reliable and efficient. Except for that bug involving object names.)

However, if you've constrained your code that carefully, you might as well not be using texts for that purpose.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group