Yet Another Toy Language To Distract Myself With

Yesterday, I made mention of Choice of the Dragon, a game I found the day before yesterday.  I also mentioned a similar game on the same site, called Choice of Broadsides.

Both of these things happen to be based on a multiple choice game engine which is scripted with a language called ChoiceScript.  I found an introductory page to the scripting language, as well as a “more advanced” page.

Which meant that I immediately and impulsively needed to write something in it, which wound up being “Guess My Number”.

Here is the listing, for any interested.

*temp guess_count
*temp answer
*temp low
*temp high
*temp guess
*temp loop

*comment ====================================================================
*comment Title Screen State
*comment ====================================================================
*label title_screen
Guess My Number (1-100)
*choice
 #Play
 *goto start_game
 #Instructions
 *goto instructions
 #Quit
 *goto confirm_quit
 
*comment ====================================================================
*comment Confirm Quit State
*comment ====================================================================
*label confirm_quit
Are you sure you want to quit?
*choice
 #Yes
 Thanks for playing!
 *finish
 #No
 *goto title_screen
*comment ====================================================================
*comment Instructions State
*comment ====================================================================
*label instructions
I will pick a number between 1 and 100, inclusive.
*line_break
You will then guess my number.
*line_break
After each guess, I will tell you if you are correct, too high, or too low.
*line_break
Once you have guessed correctly, I will tell you how many guesses it took.
*page_break Back to Title Screen
*goto title_screen

*comment ====================================================================
*comment Start Game
*comment ====================================================================
*label start_game
*set guess_count 0
*set low 1
*set high 100
*rand answer 1 100

*comment ====================================================================
*comment Make Guess
*comment ====================================================================
*label make_guess
Guess my number!
*choice
 *set loop low
 *label start_of_guess_loop
 *if (loop<=high)
 *print "#" & loop
 *set guess choice_1
 *goto evaluate_choice
 *set loop +1
 *goto start_of_guess_loop

*comment ====================================================================
*comment Evaluate Choice
*comment ====================================================================
*label evaluate_choice
*set guess_count +1
Evaluating guess: ${guess}
*line_break
*if (guess<answer)
 Your guess is too low!
 *set low guess+1
 *goto make_guess
*elseif (guess>answer)
 Your guess is too high!
 *set high guess-1
 *goto make_guess
You are correct!
*line_break
It took you ${guess_count} tries!
*line_break
Play again?
*choice
 #Yes
 *goto start_game
 #No
 Thanks for playing!

I also started throwing together a port of Hammurabi, and quickly ran into a limitation of the scripting language, which was that there was no way to do Math.floor supported within it. I later dug out that one can, indeed, punt back to Javascript using a *script command, so that’s way better than my BF-esque solution that set up a scratch variable and added 1 and subtracted two in a while loop.

So, I’m distracted by yet another toy language. This time I didn’t write it myself, and I cannot blame it on John Hattan, but tradition tells me that I must blame him anyway….

I blame John Hattan.

Advertisements

Tags: ,

2 Responses to “Yet Another Toy Language To Distract Myself With”

  1. John Hattan Says:

    That dragon game was pretty compelling, given that it was something that could’ve been written in BASIC in the 1970’s. I can definitely see a resurgence of those things.

  2. Dan Fabulich Says:

    I’m optimistic that we will see a resurgence. Be sure to let us know when you finish your port!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: