Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

A Recipe for Playing the Game of Animal

Did you ever play the game of Animal, where one person thinks of an animal and another person has to guess it? This Recipe simulates the game with a State Machine. Though it only understands a very limited number of guesses (just one - the right answer), it never gets bored. And it's an interesting example of a State Machine in action.

Each time you enter a guess, the State Machine checks to see if it is the right answer. If it is, it congratulates you. If it isn't, it tells you that as well. The State Machine has two visible terminals - a "guess" terminal for inputting your guesses, and an "output" termininal where it gives you its answers. Click on the "guess" terminal to input a guess. Note that all your guesses should be enclosed in quotes.

The Animal Game on Device Explorer
Explorer Screen Shot

Once you get the answer, trying editing the State Machine table file ("animal_game_table.yaml") and changing it so the correct guess is a different animal.

You can find the Animal game Script and table files in the Scripts "examples" area. The Script is called "animal_game.script". Just click on its "Run" action to start it running. Then start playing it by navigating to the Device Explorer page.

The Animal Game Script

The Script for the Animal game is as follows (for reference only):

# Create a state machine from the "animal" game table.

# The animal state machine has 2 visible terminals - an "output" and
# a "guess" terminal.  It also has a hidden "_state" terminal.
# Enter your guesses at the guess terminal (as quoted strings),
# and read the output to see if you are right (be sure to refresh your
# Explorer page after each guess to make sure you see the output).

run_script("Scripts/Device/Virtual/StateMachine", id:"animal_game", file_name:"Scripts/examples/virtual/state_space/animal_game_table.yaml")

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2018)




Page last updated: Tue May 20 23:26:19 2014 (UTC)