Week 9: Cleaning House (And Code)

This week, I began wrapping up my project.  Only one week remains until this thing must be worthy of demonstration in front of a class full of peers, so adding new features has to be de-emphasized in favor of reinforcing stability & adding documentation to the project.

Major New Features:

  • Added the ability to give a conditional statement.  For now, this is limited to wall sensing.  So now, “go forward until you hit a wall” is a legit command.
  • Added the ability to repeat a command a specified number of times.  i.e. “Turn left ninety degrees twice” or “Beep six times.”

Quality of Life Improvements:

  • I reorganized quite a bit of the python code and added docstrings to all the functions.
  • I added the ability to toggle voice/text input/output modes as well as debug mode.  Previously, these were command-line options or hardcoded.
  • Added punctuation filtering to user text input in order to avoid ugly crashes.  Should be a lot more user-proof now.
  • I added some more documentation to my prolog code.
  • Stabilized the photo-taking code.  It still crashes in IDLE, but works great via console python.
  • MANY small grammar reinforcements & bug fixes.

The last major feature I hope to add is a “help” menu, which will give the user an overview of commands and some examples of usage.

In the meantime, I am beginning to brainstorm about my in-class presentation and am also working on outlining my final project paper.

Next week I will post all of the sources for the final program along with a project summary.  In the meantime, here is a writeup of the full command grammar that the robot accepts:

ScribPro Command Grammar

Commands entered into the parser in accordance with the following grammar will be properly parsed and executed:

Compound_Sentence = [Address] Simple_Sentence Conn_And Compound_Sentence
                  | [Address] Simple_Sentence

Simple_Sentence   = Command_Phrase (Number “times” | Number_Eng)
                  | Command_Phrase

Command_Phrase = Move_Command
               | Move_Command Cond_Until “you” Cond_Encounter Obj_Wall
               | Turn [“to”] [“the” | “your”] Direction Amount
               | Turn [“to”] [“the” | “your”] Direction
               | Turn Around
               | Spin Around [“to”] [“the” | “your”] Direction
               | Spin Around
               | Take Adposition_A Photomode Obj_Picture
               | Take Adposition_A Obj_Picture
               | Beep
               | Wait ["for"] Amount
               | Wait
               | Moonwalk [“for”] Amount
               | Moonwalk

Move_Command   = Go Direction [“for”] Amount
               | Go Amount Direction
               | Go Amount
               | Go Direction

Adposition_A   = “a” | “one”

Cond_Until     = “until”
Cond_Encounter = “encounter” | “reach” | “sense” | “hit”

Photomode      = Photomode_0 | Photomode_1
Photomode_0    = “grayscale” | “greyscale” | “gray” | “grey”
               | “black” ”and” ”white” | “black” ”&” ”white”.
Photomode_1    = “color”

Obj_Picture    = “photo” | “picture” | “pic” | “snapshot”
Obj_Wall       = “a” ”wall” | “the” ”wall” | “an” ”obstacle” | “something”

Pronoun_Robot  = “robot” | “scribbler”

Conn_And   = “and” | “then” | “,” | “and” “then”
           | “,” “then” | “,” “and” “then”

Address    = [“robot” | “scribbler”] [“,”] [“please”]

Action     = Go | Turn | Spin | Take | Wait | Beep | Moonwalk
Go         = “go” | “move” | “drive” | “roll” | “scoot”
Turn       = “turn” | “rotate” | “swivel”
Spin       = “spin”
Take       = “take” | “obtain” | “get” | “snap”
Wait       = “wait” | “pause” | “stop”
Beep       = “beep”
Moonwalk   = “moonwalk”

Direction  = Forward | Backward | Left | Right | Around
Forward    = “forward” | “forwards” | “ahead” | “up”
Backward   = “backward” | “backwards” | “back”
Left       = “left” | “counter-clockwise” | “counter” ”clockwise”
Right      = “right” | “clockwise”
Around     = “around” | “in” Adposition_A  ”circle”

Number     = Num “point” Digit
           | Num
Number_Eng = “once” | “twice” | “thrice”
Num        = “zero” | Xxxx | Xxx | Xx | Digit | Integer
Xxxx       = Digit “thousand” Xxx
Xxx        = Digit “hundred” Rest_Xxx
Rest_Xxx   = “and” Xx | Xx | λ
Xx         = Digit | Teen | Tens Rest_Xx
Rest_Xx    = Digit | λ
Digit      = “one” | “two” | “three” | “four” | “five” | “six”
           | “seven” | “eight” | “nine”
Integer    = (*Integer is just a meta integer, i.e “242”*)
Teen       = “ten” | “eleven” | “twelve” | “thirteen” | “fourteen”
           | “fifteen” | “sixteen” | “seventeen” | “eighteen” | “nineteen”
Tens       = “twenty | “thirty” | “forty” | “fifty” | “sixty”
           | “seventy” | “eighty” | “ninety”

Amount     = Number “seconds”         (*Number != 1*)
           | Number “second”          (*Number == 1*)
           | Number “milliseconds”    (*Number != 1*)
           | Number “millisecond”     (*Number == 1*)
           | Number “feet”            (*Number != 1*)
           | Number “foot”            (*Number == 1*)
           | Number “inches”          (*Number != 1*)
           | Number “inch”            (*Number == 1*)
           | Number “degrees”         (*Number != 1*)
           | Number “degree”          (*Number == 1*)

Legend for the EBNF-unsavvy:

  • Nonterminal symbols are Capitalized.
  • Terminals are in “quotes”.
  • []’s denote optional symbols.
  • | denotes alternation.
About the Author: Justin
A 34 year old Software Engineer in Seattle, WA with a love for coding, music, video games, and the great outdoors.
Author Website: http://www.justinmangue.com

Leave a Reply

Your email address will not be published. Required fields are marked *