intfiction.org

The Interactive Fiction Community Forum
It is currently Fri Nov 16, 2018 6:24 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Oct 12, 2018 3:13 pm 
Offline
User avatar

Joined: Mon Jun 11, 2018 3:15 pm
Posts: 17
Note: This first part is a bunch of background that may actually be pointless. The question is clearly marked at the end of this post. Also note that code snippets are just that. You need the framework from the example to run them.

I have been playing around with Example #323 Quiz Show in The Inform Recipe Book. My goal is to expand the game so that the player can review correct answers and the game stops asking if the answer is correct.

The second part was easier than the first:
Code:
Carry out guessing a topic :
   choose row with state of current state in the Table of Dates of Statehood;
   say "Correct! [comment entry] to be exact!
   blank out the whole row;

The first part didn't go as well as I would have liked. You see, I had expanded the Table of Dates of Statehood to include more information, and I didn't like blanking out the row. When the player guesses the correct answer, I had to store everything in a Table of Guessed Answers. Things get really confusing if the table has columns with the same name. So, this is what I did:
Code:
Carry out guessing a topic :
   choose row with state of current state in the Table of Dates of Statehood;
   say "Correct! [state entry] became a state on [comment entry] of that year.
 It is the [admitted entry] state to be added to the Union.
 Before that, it was [origin entry]. Good job!";
   let N be the substituted form of "[admitted entry]: [state entry] [comment entry], [year entry] from [origin entry]";
   blank out the whole row;
   choose a blank row in the Table of Guessed Answers;
   now the answer entry is N;

Table of Dates of Statehood
Admitted   State   Year   Comment   Origin
"1st"   "Delaware"   "1787"   "December 7th"   "The Colony of Delaware"
"2nd"   "Pennsylvania"   "1787"   "December 12th"   "The Proprietary Province of Pennsylvania"
"3rd"   "New Jersey"   "1787"   "December 18th"   "The Crown Colony of New Jersey"
"4th"   "Georgia"   "1788"   "January 2nd"   "The Crown Colony of Georgia"

Table of Guessed Answers
Answer(text)
with 50 blank rows

The problem with this approach is that it doesn't allow flexibility. I only get one way to format the review. The system just runs out a list of rows in the Table of Guessed Answers. To get more flexibility, I get into tediously copying each Dates of Statehood column into a temporary variable and then copying it back out into the Guessed Answers table. Furthermore, if I want to do anything more with the Table of Dates of Statehood, I can't. The information is lost.

I would love to add a column to the Dates of Statehood table (or keep an array of rows) that indicates whether or not the answer is guessed. But selecting filtered data from the table seems impossible.

So I guess here's the Actual Question:
Is there some way of filtering table data like SQL so
Code:
choose a random row in the Table of Dates of Statehood;
could become something like:
Code:
choose a random unguessed row in the Table of Dates of Statehood;
[or maybe]
choose a random row in the Table of Dates of Statehood where the guessed entry is false;

Hmm?

_________________
~Esad


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Oct 12, 2018 4:41 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 362
You could do this:
Code:
sort the Table of Dates of Statehood in random order;
choose a row with guessed of false in the Table of Dates of Statehood;


("Choose a row" always picks the first row satisfying the condition, so you need to randomise the order first. If you need to return your table to its original order at any point, you can do that easily by sorting it on the "admitted" column.)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Oct 13, 2018 12:10 am 
Offline

Joined: Fri Oct 18, 2013 10:13 am
Posts: 2664
Location: The Midwest
If a phrase "choose a random row in the TABLE where the COLUMN entry is VALUE" would be useful, it wouldn't be too difficult to write an extension for it. (Linear time at best, of course, since it can't modify the table or expect it to be sorted, but that shouldn't really matter here.)

_________________
Daniel Stelzer


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Oct 17, 2018 4:17 pm 
Offline
User avatar

Joined: Mon Jun 11, 2018 3:15 pm
Posts: 17
I think I'll stick with jrb's solution. Writing an extension is a bit beyond the scope of what I want to learn right now. I mean, it's shiny and all, but I have to rein in the requirements, or I'll never finish my objective.

Thanks for the help.

_________________
~Esad


Top
 Profile Send private message  
Reply with quote  
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: Bing [Bot], KitParsing and 26 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