Community

SCI Programming => SCI Syntax Help => Topic started by: gumby on December 11, 2010, 05:17:23 PM

Title: Vocab.900 - The 'Black Box'
Post by: gumby on December 11, 2010, 05:17:23 PM
I've been trying to understand the parse trees (using the FreeSCI parser documentation heavily).  Making good progress, I think.

Am I correct in thinking that this resource holds all valid combinations of said strings?  For example:  the user input 'turn on flashlight' translates to word classes of 'verb preposition noun', which has the corresponding hexadecimal values of 800 010 100.  And I can see some word classes referenced in some of the parser rules in the resource.  Also, I can see that the resource also refers to the 3 possible parts of the said string (predicate/subject/suffix) & some terminal values, but I haven't cracked it yet.

Not exactly expecting help here, I guess this is just a status report...
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 11, 2010, 05:43:47 PM
Dude, you're awesome for tackling all this. I barely understand how this stuff works to begin with and you're just powering through! The parser is definitely the most ambiguously documented feature of the SCI engine.
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 11, 2010, 09:40:18 PM
Hey, thanks.  It's basically necessary that I understand this stuff for my port of Zork to SCI.  At this point, it's all up to parser for any of it to work so might as well figure it all out.  I would hate to do something the hard way if the parser already has provisions for it.
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 12, 2010, 03:40:37 PM
Okay, I'm on my way.  I've dissected the file & I think I've got it.  It's all the parse tree rules - I re-read (and continue to do so) the great parser info from FreeSCI.  I've inputted all the trees into a spreadsheet & am attempting to convert it from 'symbol-based' to something that I can post here & explain without getting lost in the technical details.
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 12, 2010, 09:47:32 PM
We'll have to give you a whole section on the Wiki for all you've worked out about the parser. I don't think anyone has teased out how to use the parser as much as you have in a how to way, at least not having also documented it with as much detail. Looking over Brain's help file I have found a lot of general SCI information, but not as much explaining how to use it. Perhaps I'll find more of that in his tutorial when I get back to entering it into the Wiki.

Edit: I have added an "Exploring the Parser (http://sierrahelp.com/SCI/Wiki/index.php?title=Exploring_the_Parser)" link in the navigation bar to link all of the parser stuff.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 13, 2010, 01:07:54 AM
That is fan-flipping-tastic. This is going to be one loaded and super useful Wiki!
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 13, 2010, 02:54:53 AM
That is fan-flipping-tastic. This is going to be one loaded and super useful Wiki!
I think so. I only have about 30 more pages to do of the help files and then I can move back to the tutorial. You will be able to load the Wiki in one tab and the Help files in the other for easy reference. Both have links to each other at the top of their nav boxes. I imagine many will have them loaded in their browsers as they work on their SCI projects.
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 14, 2010, 12:29:36 AM
Here's my first try at explaining this:

Basically, you start with your input sentence at the first rule, moving down the list until all the non-terminals' are finally replaced with 'terminals'.  Not all rules apply to all parses, and sometimes a parse will arrive at a 'dead-end', where the parser will 'walk' back up the tree & try the next possible rule.  Note that there can be duplicate rules strings for any one rule number (I've separated them by rule number in the table below).

Important notes:  This grammar is ambiguous!  This means that you could parse an input sentence multiple ways (I won't show it here, but trust me).  There are several things that overcome this problem.  First of all, it is a left-handed parse (meaning we always proceed left-to-right through our input string matching tokens (words).  Second, order of rules in the grammar matter, resulting in the first complete parse is what is accepted - a rule higher up in the list takes precedence in the parse.


First, I've translated the hex 'operators' into abbreviated actual values.  Here is the table for that:

AbbrTypeExplanation
---------------------------
PredNon-terminalPredicate part: This identifies the first part of a sentence
SubjNon-terminalSubject part: This identifies the second part of a sentence
SuffNon-terminalSuffix part: This identifies the third and last part of a sentence
RefeNon-terminalReference part: This identifies words that reference another word in the same sentence part
mClaTerminalMatch on class mask
mWorTerminalMatch on word group         ---Note, does not appear in this grammar
ForcTerminalForce storage: Apparently, this was only used for debugging.         ---nor does this

Let's start with an example 'open door' to walk through the table.  For reference, open is an imperative verb while door is a noun.  For now, we will ignore the meanings & focus on the 'values'.  Note that the rules that actually apply to the successful parse are indicated with a red step number.

StepGrammar RuleNotes
01.013f -> 013cReally just a placeholder.  It instructs us to proceed to rule 013c.
02.013c -> 013bThe first rule in the 013c 'set' instructs us to proceed to rule 13b.
03.013b -> 0136, 013bThe first rule in the 013b 'set' instructs us to proceed to rule 0136.
04.0136 is a terminal rule, the 'indicative verb'Not a match to our first word in our input string (looking for an imperative verb).
05.013b -> 0136, 0130, 013b0136 is no match (same as #4 above)
06.013b -> 01360136 is no match, skip
07.013b -> 0136 0133 012f0136 is no match, skip
08.013b -> 0136 0133 0133 013f0136 is no match, skip
09.013b -> 012f
10.012f is a terminal rule - the 'imperative verb'A match for our 1st token in our input string!
11.Now the 2nd token in our input stringStart back at the beginning of the parse rules...
12.013f -> 013c
13.013c -> 013bskip all (9) 013b rules dead-end with no match on our noun terminal (0130).  Details removed for brevity...
14.013c -> 013dproceed to rule 013d
15.013d -> 0131, 0139skip - we don't have enough input tokens left to fulfill this rule
16.013d -> 0131, 013a, 0139skip, not enough input tokens
17.013d -> 013askip - ultimately dead-ends with no 0130 to match our noun...
18.013d -> 0139proceed to this rule...
19.0139 -> 0130, 0135, 013dskip, not enough tokens
20.0139 -> 0130, 0139skip, not enough tokens
21.0139 -> 0130proceed...
22.0130 is a terminal rule - the 'noun'a match for our 2nd token in our input string!
23.Finished.  No more tokens.

Here's a recap of which rules actually contributed to our parse:
StepInput stringNext rule / notes
0.open doorBefore parse...
1.013f door(next rule: 013c)
9.013c door(next rule: 012f)
10.012f door(terminal, imp,verb - done with token 1)
12.012f 013f(starting at beginning of parse tree with 2nd token)
14.012f 013c(next rule: 013d)
18.012f 013d(next rule: 0139)
21.012f 0139(next rule: 0130)
22.012f 0130(terminal, noun - done with token 2)
23.Done
Note:  In many of the rules above, I cheated for brevity.  Technically, we should take the first rule in the list & navigate all the way down the 'tree' (or parse rules) to a terminal (if possible).  If all the tokens in a parse are terminated, but there are 'incomplete' rules (rules left in the parse, but no tokens to apply them to), then it's treated as 'no match'.

Here all the parse rules in the 'black box', represented in order.  Note that M is the 'meaning' of V, the value.

Rule  (M)   (V)   (M)   (V)   (M)   (V)   (M)   (V)
----  ----  ----  ----  ----  ----  ----  ----  ----
013f  Pred  013c

013c  Pred  013b
013c  Pred  013b  Subj  013d  Refe  0133
013c  Pred  013b  Subj  013d  Refe  013a
013c  Pred  013b  Subj  013d  Refe  0137
013c  Pred  013b  Subj  013d
013c  Pred  013b  Subj  013d  Refe  0133  Suff  013d
013c  Pred  013b  Suff  013d  Subj  013d
013c  Pred  013b  Subj  013d  Suff  013e
013c  Pred  013b  Suff  013e
013c  Subj  013d
013c  Subj  013d  Suff 013e
013c  Refe  013b  Refe 013d Refe 0133 Pred 013c
013c  Refe  013d  Pred 013c

013d  0145  0131  Pred  0139             // I have *no* idea what operator 0145 corresponds to
013d  0145  0131  Refe  013a  Pred  0139  
013d  Refe  013a  Pred  0139
013d  Pred  013a
013d  Pred  0139

013e  Refe  0138  Pred  013d
013e  Refe  0136  Pred  013d
013e  Refe  0138  Pred  0136  Refe  013d
013e  Refe  0138  Pred  0136  Refe  0132
013e  Pred  013b
013e  Refe  013b  Pred  013e
013e  Refe  0138  Pred  013d  Refe  0133  Refe  013d

0139  Pred  0130  0145  0135  Pred  013d
0139  Refe  0130  Pred  0139
0139  Pred  0130

013b  Refe  0136  Pred  013b
013b  Refe  0136  Refe  0130  Pred  013b
013b  Pred  0136
013b  Refe  0136  Refe  0133  Pred  012f
013b  Refe  0136  Refe  0133  Refe  0133  Pred  012f
013b  Pred  012f
013b  Pred  012f  Refe  0133
013b  Pred  012f  Refe  0133  Refe  0133
013b  Pred  012f  Refe  013a
013b  Pred  012f  Refe  0137
013b  Refe  0137  Refe  0137  Pred  013b
013b  Refe  0137  Pred  013b
013b  Pred  0137
013b  Refe  0137  Refe  0130  Pred  013b
013b  Pred  012f  0145  0135  Pred  012f
013b  Pred  012f  Pred  012f  0145  0135  Pred  012f

013a  Pred  0132
013a  Refe  0132  Pred  013a

(Terminals)
0137  mCla  0400   // Adverb  
012f  mCla  0800  // Imperative Verb
012f  mCla  0200  // Indicative verb
0136  mCla  0200  // Indicative verb
0130  mCla  0100  // Noun
0134  mCla  0080  // Pronoun
0132  mCla  0040  // Adjective
0131  mCla  0020  // Article
0133  mCla  0010  // Preposition
0138  mCla  0008  // Special
0135  mCla  0004  // Special

In my next post, I'll explain the other part of the parse - the semantic part... (using the other tokens in the grammar we did not touch on here, the subject, predicate, suffix & reference).  From this exercise we have all the 'words' for the Said() string; the semantic part will determine the way the words are 'joined' together in the said string ('/', '<', etc).
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 14, 2010, 09:48:18 AM
Someone had asked at one point how the developers at Sierra handled some of the 'ugly parses'.  I believe the answer to that lies in the the semantic token (0x14d) terminal token - which is a match on word group.

The existing 'black box' currently does not use the 'match on word group' token.  However, it could be used if you had some off-the-wall sentence that you needed special handling.  Just plug in a couple more rules with the word groups you want and have some special parse rules for those words.  I'll have to hack an example together later (maybe we ought to try 'basket of goodies' or something that doesn't seem to work right out of the box... focus on the 'of' word group here).

I also had another revelation.  The black box combined with the ability for words to have synonyms (word groups) totally addresses game internationalization.  I know I've seen a game by Robin that is all in French, I assume it uses the same black box as the other games (don't know how this works, maybe the black box works just fine with romantic languages?  Perhaps it was created with foresight & all the parse rules are already there for multiple languages?).

My point is that translating a game to a different language would be a 3 step process:
1.  Update the vocab to have synonyms for all the used words in the foreign language
2.  Update/Replace the black box with rules that make sense for the foreign language
3.  Translate all user output (text resources, etc) to the foreign language.

Hell, you could have one game support multiple languages and have the user select their desired language in the user preferences (assuming the parser could handle parse rules from both languages simultaneously).  You'd have 2 sets of text resources, one for each language, but that's no problem.  

This is unbelievably awesome coming from an engine so old.  Internationalization is still a major problem in today's computing world with current applications.  I am friggin' impressed.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 14, 2010, 10:47:17 AM
Sierra was always way ahead of its time in eveything they did. It's impressive but certainly not surprising to me. Sierra was awesome.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 15, 2010, 05:09:21 PM
To be honest I never spent much time looking into decoding SCI back when I was writing all those tools and specs for AGI. But having worked as a Java developer for the past 13 years, it occurs to me now that the way SCI works seems to be quite similar to Java. Doesn't SCI have a VM that the scripts compile to? And it's object oriented as well. Sounds very much like Java.

I guess the only difference is the Lisp syntax. Nowadays we have languages like Clojure that are lisp-like and compile to the Java VM, so that's even closer.

Yes, Sierra were definitely way ahead of their time. They were building the SCI system back in 1987 but Sun didn't build Java until around 1991 (Oak language as it was called then).
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 15, 2010, 05:25:28 PM
Doesn't SCI have a VM that the scripts compile to? And it's object oriented as well. Sounds very much like Java.

Here is information about the SCI VM:

http://sierrahelp.com/SCI/Wiki/index.php?title=Chapter_5_-_The_SCI_Virtual_Machine
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 15, 2010, 07:24:40 PM
To be honest I never spent much time looking into decoding SCI back when I was writing all those tools and specs for AGI. But having worked as a Java developer for the past 13 years, it occurs to me now that the way SCI works seems to be quite similar to Java. Doesn't SCI have a VM that the scripts compile to? And it's object oriented as well. Sounds very much like Java.

I guess the only difference is the Lisp syntax. Nowadays we have languages like Clojure that are lisp-like and compile to the Java VM, so that's even closer.

Yes, Sierra were definitely way ahead of their time. They were building the SCI system back in 1987 but Sun didn't build Java until around 1991 (Oak language as it was called then).


I assumed that SCI Studio/Companion simply used the lisp-like syntax as it's development language.  I don't know what language Sierra might have used to create their games.  I really wish that Troflip revisited the syntactical option (seen when creating a new game) for a C/C++ style syntax.  For me, LISP = Lots of Irritating and Silly Parentheses....
Title: Re: Vocab.900 - The 'Black Box'
Post by: Omni on December 15, 2010, 10:53:10 PM
I was under the impression that SCI32 was a bastardization of lisp and C. I used to know some of the programmers on "The Realm" and that is the way it was always explained to me =p
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 16, 2010, 02:01:25 PM
Correct me if I am wrong but I thought that 10+ years back someone in the SCI community (maybe Brian) had some real snippets of SCI code. I think it came from a book or perhaps a magazine article. Not sure exactly. If memory serves me right, it was for one of the Police Quest games (I might be wrong about that but fairly sure it was a Police Quest game). I had assumed that Brian based his syntax on the short snippets of real code that Sierra had released with books or articles or interviews or whatever. I'm impressed that Brian came up with something that actually works so well given that there was such little info available.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 18, 2010, 04:52:24 PM
Another source of real SCI code (and therefore evidence of the syntax) is Quest for Glory 2. It has a more sophisticated debug mode and in fact can generate snippets of SCI code. See below an example I created this afternoon using QFG2:

(instance Test9 of Actor
   (properties
      x 103
      y 169
      z -20
      heading 0
      noun 'bob8'
      view 0
      loop 0
      cel 0
      description "Test9"
      sightAngle 90
      closeRangeDist 50
      longRangeDist 100
      shiftClick verbLook
      contClick verbGet
   )
)
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 18, 2010, 04:59:53 PM
Nice!  I wasn't aware that you could get debug output like that.  Looks like the syntax we are familiar with for sure.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 18, 2010, 06:24:57 PM
Yeah, if you load up QFG2 and then inside the game activate the debug mode (by typing "suck blue frog"), and then press ALT-W, it goes through a sequence of dialogs to define an Actor/Prop/View/Feature/PicView. It also asks for a filename. You can place the Actor/Prop/View/Feature/PicView within the current room and after you define each thing it writes the detail to the file.
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 18, 2010, 06:40:37 PM
I have been thinking that QfG2 should have been used for the template game because of the parser, though it is an SCI01 game, not SCI0.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 18, 2010, 07:08:03 PM
Yeah, it would have been a better choice. SCI01 games also have the coveted scrolling background transitions
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 20, 2010, 05:00:19 PM
I realise I've taken this post completely off topic but since we were talking about the original SCI syntax, I thought you might all be interested in a web site I just discovered:

http://www.mwilden.com/smalltalk/index.htm

I found it interesting that it mentions not only C and Lisp but also Smalltalk as part of the hybrid that is SCI. Check out this quote:

"SCI was a combination of Lisp, C and Smalltalk, but the message-passing was very much Smalltalkesque. I loved the language"

It is interesting that on the same page he says "I'm sorry, but I cannot get into Lisp" but then says he loves the SCI language. This makes me think that it may have been more Smalltalk-ish that Lisp-like. Perhaps it only had a Lisp shell but was really more like Smalltalk.

I think I might email Mark and see if he can remember much about the original syntax of the language. Worth a shot...
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 20, 2010, 05:21:39 PM
I just founds Mark's blog as well. He has a blog entry that briefly talks about the SCI language.

http://mwilden.blogspot.com/search/label/sierra%20on-line

Here's a quote:

"So imagine my delight when, soon after, I got a job with Sierra On-Line, then (1989) the most prominent adventure game company. They had actually created their own language, SCI, that was a very pure implementation of OOP. I'll never forget that first night reading the documentation on my bed and just being consumed with this language that did things I wanted to do and even things I didn't know I wanted it to do.

Ever since then, I've run into lots of people who talked about the difficulties of making the paradigm shift to OOP. But not me. It was love at first sight."

Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 20, 2010, 05:25:36 PM
There is a comment on this web site by someone who describes the SCI language as being like Smalltalk. Don't know what their source is:

http://multimedia.cx/eggs/the-interpreter/

Here's the quote:

"And quite an interesting fact: old games used byte-code so it would be easier to parse and run. For example, SCI
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 20, 2010, 10:22:42 PM
There is a comment on this web site by someone who describes the SCI language as being like Smalltalk. Don't know what their source is:

http://multimedia.cx/eggs/the-interpreter/

Here's the quote:

"And quite an interesting fact: old games used byte-code so it would be easier to parse and run. For example, SCI
Title: Re: Vocab.900 - The 'Black Box'
Post by: lskovlun on December 22, 2010, 07:31:10 PM
Quote from: Gumby
What kills me is that all things I hated (and swore would not apply in my future) during my higher education are coming back to haunt me.  Push-down automatons, context-insensitive grammars - I never thought I would ever see them in my professional career.  Of course, I have not.  But in my hobbies?  You bet...   
Since I wrote the "black box" document, I thought I'd reply to this. I wrote the document at a time when I had no formal CS education. But this file contains essentially a context-free grammar for the language understood by the parser. It's complicated a bit by some things that are hard-coded in the parser, so you probably couldn't change the black box file easily (not without being mindful of the limitations of the parser code... which we don't have).
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 22, 2010, 09:01:15 PM
Since I wrote the "black box" document, I thought I'd reply to this. I wrote the document at a time when I had no formal CS education. But this file contains essentially a context-free grammar for the language understood by the parser. It's complicated a bit by some things that are hard-coded in the parser, so you probably couldn't change the black box file easily (not without being mindful of the limitations of the parser code... which we don't have).
I was wondering about that - adding rules into the grammar.  There is only a couple (reasonable) input strings that I couldn't get to parse (of the form verb/noun/prep/prep/noun & noun-verb/noun/adverb/prep/noun).  I thought I would give it go, but I guess I won't be too surprised if it doesn't work.

Thanks for the info on this.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 24, 2010, 02:07:34 AM
I have been reminded that the name of the book that has the original SCI code snippets in it is called "King's Quest Companion". Does anyone have a copy of that book so we can verify this?
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 24, 2010, 02:35:44 AM
I don't remember anything like that in it, but then I only have the last two editions. I'll see what I can find.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 24, 2010, 12:59:41 PM
It is possible that he has the name of the book wrong. If you were able to verify this then that would be great. If you can't find anything in the book then I'll go back to him and ask if he had the title correct. It was a recollection rather than a certain fact.
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 24, 2010, 02:18:17 PM
I looked through both the 3rd and fourth editions page by page and found nothing. I believe the original KQ book was called something else, but that would have been pre SCI.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 24, 2010, 04:20:14 PM
Don't you just wish that some ex-Sierra employee somewhere still has the SCI source code somewhere? Maybe even  the source for a game or two...
Title: Re: Vocab.900 - The 'Black Box'
Post by: Omni on December 24, 2010, 04:27:09 PM
Don't you just wish that some ex-Sierra employee somewhere still has the SCI source code somewhere? Maybe even  the source for a game or two...

I just wish I could get it because I know a form of it still exists.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 24, 2010, 05:25:13 PM
Where? In what way?
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 24, 2010, 06:42:28 PM
There are a number of them on Facebook. I pay very little attention to my Facebook account, but have seen a number of the ex-Sierra employees there. Al Lowe may be one of the most amenable, but I don't know how much of the programming he did in the SCI era.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 24, 2010, 07:21:47 PM
Heh, in those early games he was credited as doing everything including programming. Of course, that doesn't necessarily mean he programmed the specifics of the SCI interpreter itself.
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 24, 2010, 08:26:54 PM
I doubt that he did much of any kind of programming after AGI. But still, he may still know someone who did and he is one of the most accessible of the old Sierra employees.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 24, 2010, 09:06:22 PM
He was credited for programming for all the Larry's up to 5. So he must know something about the SCI language.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 25, 2010, 01:50:28 AM
I looked through both the 3rd and fourth editions page by page and found nothing. I believe the original KQ book was called something else, but that would have been pre SCI.

I have a copy of "The Official Book of King's Quest", which did indeed have some AGI source code in it. The person who told me that there was SCI source code in King's Quest Companion was an ex-Sierra employee. But I think it was based on a memory that is nearly 20 years old. There must be some basis to it though. When I showed him a snippet of script code from SCI Companion, he asked if some of that syntax came from the SCI snippets shown in King's Quest Companion. It may be that he is remembering the AGI code snippets in the earlier King's Quest book. I'll go back to him and check.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 25, 2010, 02:41:05 AM
Don't you just wish that some ex-Sierra employee somewhere still has the SCI source code somewhere? Maybe even  the source for a game or two...

I doubt that an ex-Sierra employee would release the original source code in a way that would end up making it public. I've been discussing the original syntax with two ex-Sierra employees over the past week and even though they worked very closely with the system, they can't recall the exact syntax anymore. But they've given me a rough idea.

For starters, when I showed one of them a snippet of code from SCI Companion, he said that is definitely NOT the original syntax. He also told me that it was definitely not similar to C in anyway. This means that the method invocation mechanism that SCI Companion uses is wrong (i.e. using () as an invocation mechanism). Instead the method invocation used Smalltalk syntax, in fact it would seem that the language was more a cross between LISP and Smalltalk, but has its own set of keywords (by which I mean that those keywords in SCI don't appear to come from LISP or Smalltalk). Here is an example of syntax that is apparently closer to the original syntax. This is a snippet from SCI Companion that has been modified to use Smalltalk message sending syntax (no guarantees here that it is an exact match to the original but is closer to the original):

   (method (delete)
      (if (& signal $8000)
         (if (& signal $20)
            (gAddToPics add:   
               ((PV new:)
                  view: view
                  loop: loop
                  cel: cel
                  x: x
                  y: y
                  z: z
                  priority: priority
                  signal: signal
                  yourself:
               )
            )
         )
           (= signal (& signal $7FFF))
           (gCast delete: self)
         (if underBits
            (UnLoad rsMEMORY underBits)
            (= underBits NULL)
         )
           (super dispose:)
        )
   )

Smalltalk uses a message sending mechanism of the format:

object method: param

Smalltalk obviously doesn't have all of the LISP parentheses in there, but if we were to add those, then in the SCI language it becomes:

(object method: param)

You'll notice that kernel functions (such as Unload shown above) also do not have the ( ) around the parameters. In think this is where the LISP side of the syntax comes into it. Everything is just a list. The first item in the list is one of the following:

keyword  e.g.  (if underBits (do-something-here))
kernel function  e.g.  (Unload rsMemory underBits)
operator  e.g. (= underBits NULL)
object   e.g.  (gCast delete: self)

If parentheses exist within other parentheses then I think it is more a grouping mechanism rather than a way to pass parameters to a method. So that Unload example above is just (name-of-function param1 param2 etc).
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 25, 2010, 12:25:22 PM
This is fascinating!
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 25, 2010, 03:59:29 PM
I looked through both the 3rd and fourth editions page by page and found nothing. I believe the original KQ book was called something else, but that would have been pre SCI.

I have a copy of "The Official Book of King's Quest", which did indeed have some AGI source code in it. The person who told me that there was SCI source code in King's Quest Companion was an ex-Sierra employee. But I think it was based on a memory that is nearly 20 years old. There must be some basis to it though. When I showed him a snippet of script code from SCI Companion, he asked if some of that syntax came from the SCI snippets shown in King's Quest Companion. It may be that he is remembering the AGI code snippets in the earlier King's Quest book. I'll go back to him and check.

It sounds like we'll need to find a first edition copy of King's Quest Companion in order to verify this. I went back to double check the title and, although it is possible the title is incorrect, apparently the SCI code was only it the first edition of the book in question. Apparently there was a law suit and all proprietry information was removed from later editions.
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 25, 2010, 04:56:49 PM
http://cgi.ebay.com/Kings-Quest-Companion-1989-covers-games-IV-/360224869259?pt=US_Fiction_Books&hash=item53df134b8b
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 25, 2010, 11:34:29 PM
I doubt that an ex-Sierra employee would release the original source code in a way that would end up making it public. I've been discussing the original syntax with two ex-Sierra employees over the past week and even though they worked very closely with the system, they can't recall the exact syntax anymore. But they've given me a rough idea.

I think it's great that you've got a discussion going with previous Sierra employees regarding syntax of the language.  What an opportunity to get with those that were involved!
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 26, 2010, 01:17:52 AM
It sounds like we'll need to find a first edition copy of King's Quest Companion in order to verify this. I went back to double check the title and, although it is possible the title is incorrect, apparently the SCI code was only it the first edition of the book in question. Apparently there was a law suit and all proprietry information was removed from later editions.

I've just reread what was said. The law suit was not in relation to the publisher of the book. Instead what happened is that Sierra sued another games company (presumably for building games like theirs) and the other company used the book in its defence claiming that the book is evidence that Sierra's technology was not completely protected. - Presumably this was a reason why the proprietary information was removed from later editions.
Title: Re: Vocab.900 - The 'Black Box'
Post by: MusicallyInspired on December 26, 2010, 08:39:52 AM
Probably Accolade and their very similar adventure games (Altered Destiny and Les Manley: Search for the King). Sierra totally sued them back in the day.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 26, 2010, 11:20:08 AM
I now realise (after discussing it with Brian) who it was that first showed me the code from the book in question. It was Stuart George (aka Dark Fiber). I've just got in contact with Stuart and he does indeed remember the SCI code snippet and says he has the book. He is currently away from home, so it will be a few days until he can dig it out to confirm the title and also hopefully send through the SCI code snippets.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 28, 2010, 01:59:20 AM
I'm still waiting for confirmation from Dark Fiber but in the meantime I have contacted kimme at sierraplanet, who has a copy of many Sierra related books. The outcome of this is that King's Quest Companion is a red herring. The 1st and 2nd editions contain no SCI code at all. What kimme claims though is that the 1st edition of The Official Book of King's Quest has SCI code. Kimme says that the 2nd edition is missing the SCI code and instead has the older AGI code. This makes me think that I must have the second edition not the first because my edition only has AGI code.
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 28, 2010, 04:19:06 AM
Could she scan it for us?
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 28, 2010, 06:58:45 AM
Could she scan it for us?

I'll ask the question and see what she says. At the very least I'd imagine that she could maybe send us a couple of lines to verify that it is indeed SCI code. It is possible that she has mistakenly identified AGI code as SCI code. Unfortunately I don't have my copy of The Official Book of King's Quest on this side of the planet (it's in New Zealand and I'm living in England at the moment), so I don't know for sure if my copy is a first or second edition. I know that my copy has more than one snippet of AGI code but definitely no SCI code. I remember thinking at the time I bought it that it was strange that it didn't have SCI code because all the photos of the tools (picture editor, view editor) were of the SCI tools, and I seem to recall that the discussion in the book about the "making of" King's Quest was related to the SCI version....   and yet all the code snippets were AGI. I guess that supports what kimme is saying about the second edition having the older AGI code. I'll go back to her and ask a few questions.

Dark Fiber should be able to give us his report in the next day or so.
Title: Re: Vocab.900 - The 'Black Box'
Post by: lance.ewing on December 28, 2010, 07:29:06 AM
I've gone back to ask the question, but the more I think about it, the more I'm thinking that this might end up being a red herring as well. I've included below Kimme's exact response:

"in the first edition of "The Official Book of King's Quest" by Donald
B. Trivette, there are SCI code snippets for smoke, opening/closing a
house door, and falling on rocks in the "Script Interpreter" section of
"Chapter 2: The Making of King's Quest 4" (pages 17 to 20).

The 2nd edition doesn't have the codes reprinted. It just has a small
snippet of older AGI coding demonstrating how smoke moves in "Chapter 2:
The Making of Quests" (page 20)."


The reason I am starting to think that it might be a red herring is because I clearly remember that my copy of The Official Book of King's Quest had code in it for "smoke", "falling on rocks", and "opening and closing a house door", i.e. all of the things that Kimme mentions as being SCI code. My copy had AGI code though. Kimme says that the 2nd edition only had AGI code for the smoke but I'm certain my copy had AGI code for the others as well. So unless there is an in between edition (i.e. a first edition with the code changed to AGI instead) then I think it might end up being AGI code that she has seen. I've sent her some examples of AGI and SCI code, highlighting the differences, so that she can verify which it is that she saw. I forget that not all Sierra fans know what AGI and SCI code looks like.
Title: Re: Vocab.900 - The 'Black Box'
Post by: Collector on December 28, 2010, 02:36:56 PM
Of course if it is from KQ4, it could be either. It seems like it would be easiest for her to simply scan it and email it to you.
Title: Re: Vocab.900 - The 'Black Box'
Post by: gumby on December 31, 2010, 05:30:24 PM
Okay, so I've made my first attempt at modifying the black box.  I tried to address an input of the form verb-noun-prep-prep-noun (ex: 'take larry out to dinner').  The interpreter previously had identified this input as "That doesn't appear to be a proper sentence".  Now, the interpreter just crashes when attempting to parse the input.  However, all other inputs still work (they don't cause a crash). 

This tells me that I correctly set up the grammar rule (at least partially).  Maybe I've incorrectly set the corresponding semantic values - or I'm attempting something futile.