Inform

ohjelmointikieli

Inform on Graham Nelsonin luoma oliopohjainen ohjelmointikieli tekstiseikkailupelien luomiseen. Ohjelmointikielen kääntäjä kääntää ohjelman Z-machine-muotoon; Z-machine on virtuaalikone, jota Infocom käytti omissa tekstiseikkailupeleissään. Täten Informilla kirjoitettuja pelejä voi pelata myös kaikilla Infocomin pelien pelaamiseen tarkoitetuilla tulkkiohjelmilla. Informin myötä kehitettiin myös uusia Z-machine-tiedostomuotoja, ja Inform tukee myös uudempaa Glulx-virtuaalikonestandardia.

Informista on olemassa kaksi käytössä olevaa pääversiota. Inform 6 on viimeisin stabiili uudelleen kirjoitettu versio, joka luotiin vuonna 1996 ja jota on paranneltu pitkälti sen jälkeen. Inform 7 on beta-asteella; Inform 7-kääntäjä kääntää koodin ensiksi Inform 6-koodiksi, joka puolestaan automaattisesti käännetään Inform 6-kääntäjällä. Inform 7 sisältää myös Microsoft Windows- ja Mac OS X -versioissa ohjelmointiympäristön, jossa on monia tekstiseikkailujen tekemistä helpottavia työkaluja. Kääntäjästä on myös Linux-versio.[1]

Inform 6 on pitkälti normaali olio-ohjelmointikieli, mutta Inform 7:n syntaksi on lähellä luonnollista englannin kieltä, koska tämä helpottaa kuvausten kirjoittamista ja vähentää ohjelmoinnin vaikeutta. Inform 7:ää kutsuttiinkin varhaisessa kehitysvaiheessa "Natural Informiksi".

Inform 6 -ohjelma muokkaa

Esimerkki Inform 6 -ohjelmasta:

 Constant Story "Hello World";
 Constant Headline "^An Interactive Example^";

 Include "Parser";
 Include "VerbLib";

 [ Initialise;
     location = Living_Room;
     "Hello World";
 ];

 Object Kitchen "Kitchen";
 Object Front_Door "Front Door";

 Object Living_Room "Living Room"
     with
         description "A comfortably furnished living room.",
         n_to Kitchen,
         s_to Front_Door,
     has light;

 Object -> Salesman "insurance salesman"
     with
         name 'insurance' 'salesman' 'man',
         description "An insurance salesman in a tacky polyester 
               suit.  He seems eager to speak to you.",
         before [;
             Listen:
                 move Insurance_Paperwork to player;
                 "The salesman bores you with a discussion
                  of life insurance policies.  From his
                  briefcase he pulls some paperwork which he
                  hands to you.";
         ],
     has animate;

 Object -> -> Briefcase "briefcase"
     with
         name 'briefcase' 'case',
         description "A slightly worn, black briefcase.",
     has container;

 Object -> -> -> Insurance_Paperwork "insurance paperwork"
     with
         name 'paperwork' 'papers' 'insurance' 'documents' 'forms',
         description "Page after page of small legalese.";

 Include "Grammar";

Esimerkki Inform 7-ohjelmasta muokkaa

"Hello World" by "I.F. Author"

The story headline is "An Interactive Example".

The Living Room is a room. "A comfortably furnished living room." The Kitchen is north of the Living Room. The Front Door is south of the Living Room. The Front Door is a closed locked door.

The insurance salesman is a man in the Living Room. The description is "An insurance salesman in a tacky polyester suit. He seems eager to speak to you." Understand "man" as the insurance salesman.

A briefcase is carried by the insurance salesman. The description is "A slightly worn, black briefcase." Understand "case" as the briefcase.

The insurance paperwork is in the briefcase. The description is "Page after page of small legalese." Understand "papers" or "documents" or "forms" as the paperwork.

Instead of listening to the insurance salesman:

    say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you.";
    now the player carries the insurance paperwork.

Lähteet muokkaa

Aiheesta muualla muokkaa

Tämä tietotekniikkaan liittyvä artikkeli on tynkä. Voit auttaa Wikipediaa laajentamalla artikkelia.