Computers by Emily Short


"Computers" implements a basic computer set-up. Implemented computers have peripherals: such as a screen and keyboard by default, and others optionally. They may run software; several types of default software are provided. They may also have data ports of various sorts, though the behavior of these ports is minimally elaborated here.

By itself, "Computers" does not implement cords or batteries and does not worry about computer power supplies. However, if we include Power Supplies by Emily Short (which also requires Plugs and Sockets by Sean Turner), we will get power cords for our desktop computers and a combination of cords and batteries for laptops.

Chapter: Hardware

Section: The computer kind; screens and keyboards

A computer is implemented as a device that may be switched on and off. "Computers" supplies every computer with a screen (which can also be called "monitor" by the player) and a keyboard. The keyboard is required for the computer to understand typing; if one is absent, the player will not be able to enter typed commands.

When switched on, a computer plays a startup noise and displays the contents of its screen. We may change the startup noise so:

The startup noise of the PC is "[The item described] [chime] cheerfully."

The contents of the computer's screen will depend on what software the computer is currently running. (See below.)

Section: Laptops and desktops; mice and trackpads

"Computer" has two subordinate kinds, "laptop" and "desktop computer". A laptop may be opened or closed (synonymous with switching it on and off, for simplicity) and has a trackpad. A desktop computer is by default fixed in place and has a mouse.

For non-standard configurations of computer, such as an ATM with a modified keyboard and no mouse/trackpad, we would fall back on the base "computer" kind and add the desired components by hand.

Trackpads and mice are both of the kind "selection device". If a computer does not incorporate any selection device, the player will not be able to click on things to select them on that computer. If we wished to implement a different type of console, we might alternatively make joysticks, touchpads, or trackballs as selection devices.

Section: Extension ports

"Computers" also has the concept of an "extension port", which is a generic kind suitable for implementing DVD or CD drive slots, USB ports, and any other realistic or futuristic reader for a data storage device; and the kind "data storage device", which is the only sort of item that may be placed into an extension port. An extension port may contain exactly one thing at a time.

So for instance we might write

The CD slot is an extension port. It is part of the old PC.

The CD-ROM is a data storage device.

... whereupon the CD-ROM may be placed in the CD slot, but nothing else will be permitted.

The extension assumes that the player who types

INSERT STORAGE DEVICE INTO COMPUTER

really means to insert the storage device into the extension port that is part of the computer. Input will be redirected automatically if a given computer has only one extension port and the situation is unambiguous.

If we have a game in which multiple types of data storage devices exist and are to be placed in multiple types of extension ports, we may need to add subkinds of these two kinds, and restrict more thoroughly which storage devices may be put into which ports.

Furthermore, there is no default treatment of data storage devices or their effect on computers or computer software, as the possibilities are too diverse. We should decide on a per-game basis what happens when a given storage device is hooked up.

The examples show a very simple way to a storage device to extend the range of a search engine program.

Chapter: Software

Section: Software in general

A given computer may be running one or more pieces of software; whichever software is currently dominant receives the input sent by the keyboard, and is also visible when the player looks at the screen or the computer as a whole.

The appearance of the software on the screen is given by the software's description. Thus we might have

The PC runs a password-lock program called rudimentary passcode. The description of rudimentary passcode is "[regarding the noun]A box on the screen [invite] [us] to type a password to proceed."

A computer can run several programs at once, in which case the program with the lowest "software priority" is the one that is considered to be working and receiving input at the moment. By default, most software has a software priority of five, while password-lock programs have software priority 1 (meaning they must be dealt with before other software becomes available). If it is intended that the user can change programs manually, we might handle this by changing software priorities during play to make the one in use uppermost; as in

now the software priority of the email program is 1.

When the player uses a TYPE or CLICK ON command, the topic understood is passed on to the input handling rules. The input handling rules are an object-based rulebook and are keyed to the specific program currently dominant on the computer. One of the several input handling rules looks like this:

An input handling rule for a multiple-choice program (called chosen software) (this is the pick a choice rule):
     if the topic understood is a topic listed in the options table of the chosen software:
         follow the effect entry;
         rule succeeds;
     otherwise:
         say "[out-of-bounds response of the chosen software][paragraph break]";
         rule fails.

... and consequently we can make new input handling rules for any new software we write, or to customize the behavior of the default software kinds.

Section: Default software kinds

Five types of software are provided by default:

(1) a password-lock program that renders the computer inoperable until the password is typed

(2) a search program that returns results on typed searches, as well as to standard syntax such as LOOK UP "whatever" IN SEARCH PROGRAM

(3) a multiple-choice program that allows the user to select options, and runs rules accordingly

(4) an enumerated multiple-choice program (the same kind of thing, but assigning a number to each choice instead of matching them with topic keywords)

(5) an email program capable of organizing incoming and outgoing messages, marking which messages are read, and reporting new arrivals.

Section: password-lock programs

To define a password-lock program, we may write something like:

The PC runs a password-lock program called rudimentary passcode. The password of rudimentary passcode is "xyzzy".

Note that because of the way the z-machine handles typed input, the player's input will always be flattened to lower case before it is interpreted. Therefore passwords should always be in lower case.

We may also optionally define two other aspects of a password-lock program, namely the text displayed when the player's attempt fails, and that displayed when it succeeds. Thus:

The rejection of rudimentary passcode is "'Password incorrect.'"
The success of rudimentary passcode is "The password field vanishes."

Section: Multiple-Choice Programs

A multiple-choice program is one that presents the player with a series of choices to type or click on, and executes a rule whenever one is selected. This is suitable for setting up operating systems, dedicated special-purpose computers such as ATMs, or other interfaces that involve negotiating a series of menus. Items from a multiple-choice list may be selected by typing or by mouse or trackpad if one of these is available.

To set up a multiple-choice program, we must establish an options table like so:

The operating system is a multiple-choice program. The options table of the operating system is the Table of GUI Options.

Table of GUI Options
topic     title     effect
"microsoft/word" or "microsoft word"     "Microsoft Word"     open-Word rule
"adobe illustrator" or "adobe/illustrator"     "Adobe Illustrator"     open-Illustrator rule

If we wish a multiple-choice program to function as an operating system allowing access to various other programs on the computer, we might use these effect rules to change the software priority of other programs.

A subkind of multiple-choice program is the enumerated multiple-choice program, for when we wish the player to make a selection by number. Here instead of providing a topic list, we provide an index column, which will contain numbers (but, as these will be chosen at runtime, we do not need to specify them ourselves). We may add lines to the table or remove them again if we wish to change the player's available options.

The ATM operation program is an enumerated multiple-choice program. The options table of the ATM operation program is the Table of Transactions.

Table of Transactions
index     title     effect
--     "Check balance"     balance-check rule
--     "Quick cash"     quick-cash rule
--     "Buy stamps"     stamp-purchase rule
--     "Cancel"     cancellation rule

Both enumerated and regular multiple-choice programs have a response to print if the player attempts to type or select something that is not understood as an option. We may change this by altering the out of bounds response, like so:

The out-of-bounds response of the ATM operation program is "Your selection, '[topic understood]', is not one of the available choices."

Section: Search engines

To define a search engine, we must provide a table of data, such as

The PC runs a search engine called Goggle. The data table of Goggle is the Table of Goggle Data.

Table of Goggle Data
topic     title     data
"food/cake/yellow" or "yellow cake"     "OnlineRecipes.org"     "A delicious recipe for yellow cake."
"yellow balloon" or "yellow/balloon"     "PartyPlanning.com"     "How to order yellow balloons online."

By default, in keeping with the behavior of real search engines, this search engine will go through and match every possible topic on the list, reporting all hits, rather than matching only the first instance. This means that output can be very long if the individual descriptions are themselves long, so use with discretion.

If we wish, we can define a search engine that does not rely on the topic table but actually searches the data text for whatever string the player has typed in. This is more powerful, but slower. To turn this functionality on, we should include

When play begins:
     now slow searching is true.

When slow searching is true, the search engine will ignore the topic column and instead look for the searched text in the data itself. There is an example using this behavior below.

Search engines have two pieces of text, the "no-records response" and "results-found response", as defined here:

The no-records response of a search engine is usually "No records found.".
The results-found response of a search engine is usually "Your search turns up the following results:".

... and as usual we may modify these to change the way search results are described.

Section: Email

Email is a program that allows the player to receive and read email from a list. To establish the email in an email program, we would write

The message table of laptop email is Table of Laptop Messages.

Table of Laptop Messages
topic     message     arrival time     read     answered     description
"memo"     "Memo"     9:00 AM     false     false     "Your boss would like to see you in his office right away."
"SPAM"     "SPAM"     --     false     false     "Money for you from Nigeria!"
with 10 blank rows.

Note that an arrival time is provided for "memo" but not for "SPAM". That is because memo is understood to have been delivered already, while SPAM has not. To deliver new email, we would write

deliver "SPAM" to laptop email.

This would mark the spam message, which already exists in the Table of Laptop Messages, as available for the player to read. It would also set the arrival time.

If the player is in view of a switched on computer that is running this program, the arrival of the message will be reported at the moment when it happens. The text of this report is handled by the "new mail message" of the email program, like so:

The new mail message of an email program is usually "You have new mail on [the random computer which is running the item described].".

To change this output, we would create a different new mail message for the email program in question.

Typing or clicking on one of the topic words will bring up what ever text we have put in the description field, which might be a brief summary or might be the full text of the email in question. READ email will also work.

REPLY TO email is implemented, but generally blocked by the "block replying to email" rule. This is because the behavior of replying to email is likely to vary quite a bit from game to game, depending on whether we want to allow the player some control over the email he composes and what other game-state changes result from sending that email.

If we wish to allow replies to email, we should first unlist the block replying to email rule, like so:

The block replying to email rule is not listed in any rulebook.

At that point, default behavior of the action is to mark the email replied and to report simply "You reply." It is up to us to elaborate on this in some more interesting way.

Example: * Reading Email - A laptop set up with a password-lock program that gives way to email we can read, and a new message that is delivered while we wait.

"Reading Email"

Include Computers by Emily Short.

Conference room is a room.

The conference table is a thing in the Conference Room. The small laptop is a laptop on the conference table.

The small laptop runs a password-lock program called laptop security. Laptop security is privately-named. The password of laptop security is "mulderxox".

The small laptop runs an email program called laptop email. Laptop email is privately-named.

The message table of laptop email is Table of Laptop Messages.

Table of Laptop Messages
topic     message     arrival time     read     answered     description
"memo"     "Memo"     9:00 AM     false     false     "Your boss would like to see you in his office right away."
"SPAM"     "SPAM"     --     false     false     "Money for you from Nigeria!"
with 10 blank rows.

At 9:10 AM:
     deliver "SPAM" to laptop email.

Test me with "turn on laptop / read memo / x laptop / x screen / read memo / type wrongpassword / type mulderxox / read memo / read spam / z / z / z / z / z / x screen / read spam / reply to spam".

Example: * Powered Email Machine - The same as above, except that we add Power Sources to create a laptop with a battery that can be drained of power and shut down.

"Powered Email Machine"

Include Power Sources by Emily Short. Include Computers by Emily Short.

Conference room is a room. It contains a wall socket.

The conference table is a thing in the Conference Room. The small laptop is a laptop on the conference table.

The small laptop runs a password-lock program called laptop security. Laptop security is privately-named. The password of laptop security is "mulderxox".

The small laptop runs an email program called laptop email. Laptop email is privately-named.

The message table of laptop email is Table of Laptop Messages.

Table of Laptop Messages
topic     message     arrival time     read     answered     description
"memo"     "Memo"     9:00 AM     false     false     "Your boss would like to see you in his office right away."
"SPAM"     "SPAM"     --     false     false     "Money for you from Nigeria!"
with 10 blank rows.

At 9:10 AM:
     deliver "SPAM" to laptop email.

Test me with "turn on laptop / x laptop / x screen / type mulderxox / read memo / read spam / z / z / z / z / z / x screen / read spam / reply to spam / z / z / plug in laptop / look / turn on laptop / read spam / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / z / unplug laptop".

Example: * USB Drive - A very simple implementation of a laptop that can search for and find new data when a USB stick is inserted into its extension port.

"USB Drive"

Include Computers by Emily Short.

The Ventilation Duct is a room.

The quickbook is a laptop. It is carried by the player.

The USB port is an extension port. It is part of the quickbook. The player carries a USB stick. The USB stick is a data storage device.

Generic search is a search engine. The quickbook runs generic search. The data table of generic search is the Table of Dull Data.

Table of Dull Data
topic     title     data
"myself/me/yourself/you/user/profile" or "user profile"     "your user profile"     "None of your user information has been filled in. For security reasons."

Carry out inserting the usb stick into the USB port:
     now the data table of generic search is the table of secret data.

Report inserting the usb stick into the USB port:
     say "You plug in the USB stick, making its valuable data available to the quickbook's search engine." instead.

Carry out taking the usb stick when the usb stick is in the USB port:
     now the data table of generic search is the table of dull data.

Report taking the USB stick when the USB stick was in the USB port:
     say "You deftly pull out the USB stick again." instead.

Table of Secret Data
topic     title     data
"myself/me/yourself/you/user/profile" or "user profile"     "your user profile"     "None of your user information has been filled in. For security reasons."
"Coca-Cola" or "recipe" or "coke/coca/cola"     "secret Coca-Cola recipe"     "Scrolling across your screen is the detailed secret recipe for Coca-Cola, including all the elements of the 7X formula."

Test me with "x quickbook / open it / type recipe / insert usb stick in port / look up recipe in computer / take stick / search for recipe / take stick / drop stick / take stick".

Example: * True Search - A desktop computer running a search engine that has slow search activated so that it will match any string against the searched data.

Here we're activating the "slow search" feature. The results run reasonably smoothly if there is little data, but will likely become sluggish if there is a great deal.

"True Search"

Include Computers by Emily Short.

Conference room is a room.

The conference table is a thing in the Conference Room. The old PC is a desktop computer on the conference table.

The PC runs a search engine called Goggle. The data table of Goggle is the Table of Goggle Data.

Table of Goggle Data
topic     title     data
--     "OnlineRecipes.org"     "A delicious recipe for yellow cake."
--     "PartyPlanning.com"     "How to order yellow and blue balloons online."
--     "Repainting.com"     "Suggested blue, cerise, and purple shades to use in repainting your living room."
--     "Livingwithsciatica.com"     "An assortment of resources for living with sciatica."

When play begins:
     now slow searching is true.

Test me with "turn on PC / type living / type sciatica / type blue / type yellow / type cake".

Example: ** Operations - A desktop computer running an operating system that in turn allows the player to select and run either the browser or the email program.

We're going to use a multiple-choice program to implement our operating system, and also implement "type quit" and "select quit" to let the player quit out of other programs when he wishes to return to the OS. (By default, the player is not allowed to quit running programs; this makes it easier to implement single-use computers that are good for only one function, which is quite a common arrangement in IF if not in life.)

We also want the computer to revert back to the operating system if switched off while running some other program.

"Operations"

Include Computers by Emily Short.

Conference room is a room.

The conference table is a thing in the Conference Room. The old PC is a desktop computer on the conference table.

The old PC runs a multiple-choice program called PCOS. PCOS is privately-named. The options table of PCOS is the Table of GUI Options.
     The software priority of PCOS is 1.

Table of GUI Options
topic     title     effect
"mail/email"     "Mail"     open-Mail rule
"browser/internet"     "Browser"     open-browser rule

This is the open-Mail rule:
     repeat with item running through software run by the old PC:
         now the software priority of item is 5;
     now the software priority of PC email is 1;
     say "You select the mail.";
     try examining PC email.

This is the open-Browser rule:
     repeat with item running through software run by the old PC:
         now the software priority of item is 5;
     now the software priority of Goggle is 1;
     say "You select the browser.";
     try examining Goggle.

The old PC runs an email program called PC email. PC email is privately-named.

The message table of PC email is Table of PC Messages.

Table of PC Messages
topic     message     arrival time     read     answered     description
"memo"     "Memo"     9:00 AM     false     false     "Your boss would like to see you in his office right away."
"SPAM"     "SPAM"     --     false     false     "Money for you from Nigeria!"
with 10 blank rows.

At 9:10 AM:
     deliver "SPAM" to PC email.

The PC runs a search engine called Goggle. The data table of Goggle is the Table of Goggle Data.

Table of Goggle Data
topic     title     data
"food/cake/yellow" or "yellow cake"     "OnlineRecipes.org"     "A delicious recipe for yellow cake."
"yellow balloon" or "yellow/balloon"     "PartyPlanning.com"     "How to order yellow balloons online."

Software can be quittable. A software is usually not quittable. PC email and Goggle are quittable.

A first input handling rule for quittable software (called chosen software):
     let N be indexed text;
     let N be the topic understood;
     if N is "quit":
         reset to operating system;
         say "You return to the operating system.";
         try examining PCOS;
         rule succeeds.

Carry out switching off the old PC:
     reset to operating system.

To reset to operating system:
     repeat with item running through software run by the old PC:
         now the software priority of item is 5;
     now the software priority of PCOS is 1;

After examining a quittable software (called chosen software):
     say "You can also select QUIT to return to the operating system."

Test me with "turn on PC / click browser / look up food on computer / type cake / type quit / type mail on keyboard / select memo / reply to memo / type quit / click browser / turn off PC / turn on PC / click browser / reboot".

Example: *** Balance Checking - An ATM, or automatic teller machine, that requires a debit card and pin before allowing the player access to the main menu screen. Demonstrates the use of extension ports, enumerated multiple-choice programs, and a new software kind from scratch for the welcome screen.

We make the ATM a generic computer that can't be turned on or off. We create the debit card as a "data storage device" (even though, in practice, it's not being accessed for anything important -- but this does mean that we can make the card slot automatically accept it and reject all other kinds of contents).

"Balance Checking"

Include Computers by Emily Short.

The Bank Forecourt is a room. The High Street is north of Bank Forecourt.

The ATM is a computer in the Bank Forecourt. The ATM is switched on. The ATM runs welcome screen. The description is "The ATM is the sort with a small, roughly square screen; a keypad for numeric input; and a slot in which to insert a debit card."

Carry out examining the ATM:
     say "[description of the ATM][paragraph break]";
     rule succeeds.

Instead of switching off the ATM:
     say "Resetting the ATM is only possible for bank employees."

The player carries a wallet. The wallet contains a debit card. The debit card is a data storage device. The description of the debit card is "It is a red card stamped with numbers and embossed with a hologram of a flying eagle. With a sharp needle, you scratched the PIN 2953 into the upper left corner. You're always forgetting it."

The slot is an extension port. It is part of the ATM.

Does the player mean inserting the debit card into the slot: it is very likely.

The welcome screen is privately-named software. The description of the welcome screen is "WELCOME, reads the screen. PLEASE INSERT CARD TO PROCEED."

An input handling rule for the welcome screen:
     say "INSERT CARD TO PROCEED, insists the screen.";
     rule fails.

Carry out inserting the debit card into the slot:
     now the ATM does not run welcome screen;
     now the ATM runs PIN request screen;
     now the ATM runs ATM operation program.

Report inserting the debit card into the slot:
     say "You slide your card into the slot.";
     let target screen be a random screen that is part of the ATM;
     try examining the target screen instead.

Instead of taking the debit card when the debit card is in the slot:
     say "You reclaim your card.";
     now the player carries the debit card;
     clear the ATM screen;
     rule succeeds.

Understand "insert [something]" as inserting it into.

Rule for supplying a missing second noun when inserting something into:
     if the slot is visible:
         now the second noun is the slot;
     otherwise:
         say "There is no obvious place to insert [the noun]." instead.

The PIN request screen is a privately-named password-lock program. The password of PIN request screen is "2953". The description is "The screen now reads, PLEASE INPUT YOUR PERSONAL IDENTIFICATION NUMBER." The rejection of PIN request screen is "INCORRECT IDENTIFICATION NUMBER. TRY AGAIN."

The ATM operation program is an enumerated multiple-choice program. The options table of the ATM operation program is the Table of Transactions.

Table of Transactions
index     title     effect
--     "CHECK BALANCE"     balance-check rule
--     "QUICK CASH"     quick-cash rule
--     "BUY STAMPS"     stamp-purchase rule
--     "END TRANSACTION"     cancellation rule

Price is a kind of value. $99.99 specifies a price.

Checking account balance is a price that varies. Checking account balance is $2894.82.
Cash in hand is a price that varies. Cash in hand is $15.97.

After taking inventory:
     say "You are carrying [cash in hand] in cash."

This is the balance-check rule:
     say "Your balance is [checking account balance]."

This is the quick-cash rule:
     if checking account balance is less than $20.00:
         say "Insufficient funds!" instead;
     decrease checking account balance by $20.00;
     increase cash in hand by $20.00;
     say "The machine spits out a $20 bill.";

This is the stamp-purchase rule:
     say "The machine is temporarily out of stamps."

This is the cancellation rule:
     say "The ATM ejects your debit card, which you instinctively take.";
     now the player carries the debit card;
     clear the ATM screen.

To clear the ATM screen:
     now the ATM runs the welcome screen;
     now the ATM does not run PIN request screen;
     now the ATM does not run ATM operation program;
     let target screen be a random screen that is part of the ATM;
     try examining the target screen.

Test me with "x atm / x keyboard / turn off atm / reboot atm / i / put wallet in slot / put card in slot / x card / get card / put card in slot / input 3311 / type 2953 / type 1 / input 3 on keyboard / i / input 2 / i / type 1 / type 4 / put card in atm / take card / insert card / type 2953 / take card / type 1 / n / insert card".