Virtual Pest "Startup Kit"


This page presents a "skeleton page" for a "minimal virtual pest" for use in CS 164 (Introduction to Computer Science), as described in assignments Virtual Pest I, Virtual Pest II, Virtual Pest III.

Included in the page source are functions that:

You may use these functions as guides to programming your own virtual pest.

JL Popyack, Nov. 1998. Updated Nov. 1999, 2000


Smiley, the Amazing Emoticon

Smiley behaves according to the finite-state machine and behavior table shown at the end of this document. There are four possible states. The state is updated once per second.

Click the button to pat Smiley when state is either "lonely" or "angry". When "happy" or "provoked", the state changes randomly; clicking the button will have no effect in these states.

Sound:

Action:

The pest's state: Normally, this item is hidden Step counter:


Finite State Machine:

(for reference only - you do not need to include on your web page)


Behavior Table:

(for reference only - you do not need to include on your web page)

Element

Type

Possible values

Meaning

Action

PetSound

text box

Grrr...
Woof woof

state=angry
state= lonely

OwnerHand

button

pat Smiley

changes state to "provoked" if angry, and to "happy" if lonely.

PetAction

text box

Bite
Flash the Peace Sign

state=provoked
state= happy

...

...

...

...

...