Skip to content

Recreated environment for Logo - a popular children's coding language.

Notifications You must be signed in to change notification settings

belaltaher8/SLogo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SLogo

Description

SLogo is a recreation of Logo - a popular children's coding language. Logo is a user-friendly, interpreted language, designed with a "low floor, high ceiling"; in other words, the designers of Logo intended for the language to allow novice programmers to get started quickly writing programs but also wanted the language to be powerful and extensive for more advanced users.

SLogo uses the MVC paradigm to allow the user to interact with the "turtles" (they can actually become anything you'd like if you upload a new image) on a per expression basis.

SLogo IDE

Commands

While the command names below are given in all capital letters, SLogo is not case sensitive. Note that any values used as parameters to a command may be the result of calling any of the commands below or a value stored in a variable. Thus all commands return a double value as described below. Also, commands can be formatted over any number of lines, including multiple commands on the same line, but they must be separated by one or more spaces.

Basic Syntax

Token Syntax Semantics Examples
Constant
[0-9].[0-9]
any real valued number
note, to avoid potential ambiguity in parsing there should not be a space between the negative sign and the value
50
-1.3
Variable
:[a-z or A-Z]
any word preceded by a colon, :
note, if a variable name is used that has not previously been given a value, return a default value (i.e., 0)
:distance
:side
Command
[a-z or A-Z]
any word can be a command-name
note, all commands return a numeric value
note, built-in commands are given below and user-defined commands cannot reuse those names
forward
fd
List
[
]
these brackets enclose a list of zero or more commands or variables
note, to make parsing easier, these will always be separated from other tokens by spaces
[ fd 50 rt 90 ]
Comment
#
Ignore any lines that are empty, i.e., only zero or more spaces, and lines that begin with the comment character, "#".
# a comment
#fd 50

Turtle Commands (for both a single and multiple turtles)

Name(s) Description
FORWARD pixels
FD pixels
moves turtle forward in its current heading by pixels distance
returns the value of pixels
BACK pixels
BK pixels
moves turtle backward in its current heading by pixels distance
returns the value of pixels
LEFT degrees
LT degrees
turns turtle counterclockwise by degrees angle
returns the value of degrees
RIGHT degrees
RT degrees
turns turtle clockwise by degrees angle
returns the value of degrees
SETHEADING degrees
SETH degrees
turns turtle to an absolute heading
returns number of degrees moved
TOWARDS x y turns turtle to face the point (x, y), where (0, 0) is the center of the screen
returns the number of degrees turtle turned
SETXY x y
GOTO x y
moves turtle to an absolute screen position, where (0, 0) is the center of the screen
returns the distance turtle moved
PENDOWN
PD
puts pen down such that when the turtle moves, it leaves a trail
returns 1
PENUP
PU
puts pen up such that when the turtle moves, it does not leave a trail
returns 0
SHOWTURTLE
ST
makes turtle visible
returns 1
HIDETURTLE
HT
makes turtle invisible
returns 0
HOME moves turtle to the center of the screen (0 0)
returns the distance turtle moved
CLEARSCREEN
CS
erases turtle's trails and sends it to the home position
returns the distance turtle moved

Display Commands

Note, for commands below that receive/return an index number, that index should refer to a list of graphical items (like an image or color) whose items are clearly available in the GUI with their number or order apparent (so the user knows how to refer to them within a command). Also, it would be helpful to populate each list with some initial default choices for the user.

Command Description
SETBACKGROUND index
SETBG index
sets background color of screen to that represented by index
returns given index
SETPENCOLOR index
SETPC index
sets color of the pen to that represented by index
returns given index
SETPENSIZE pixels
SETPS pixels
sets size of the pen to be pixels thickness
returns given pixels
SETSHAPE index
SETSH index
sets shape of turtle to that represented by index
returns given index
SETPALETTE index r g b sets color corresponding at given index to given r g b color values
returns given index
note, color component values are nonnegative integers less than 256 specifying an amount of red, green, and blue
PENCOLOR
PC
returns turtle's current color index
SHAPE
SH
returns turtle's current shape index

Multiple Turtle Commands

Command Description
ID returns current active turtle's ID number
ID values typically start at 1 and increase by 1 with each new turtle created
note, there is technically only one "active turtle" at any given time since each command is run once for each active turtle, i.e., this value can always be used to identify the current turtle running the command
TURTLES

returns number of turtles created so far
TELL [ turtle(s) ] sets turtles that will follow commands hereafter
returns last value in turtles list
note, if turtle has not previously existed, it is created and placed at the home location
note, if more than one turtle is active, commands run return value associated with the last active turtle
ASK [ turtle(s) ]
[  command(s) ]
only the turtles given in first list all run commands given in the second list
returns result of last command run by the last turtle
note, after commands are run, currently active list of turtles returns to that set by the last TELL command (or default active turtle if TELL never given)
note, if more than one turtle is active, commands run return value associated with the last active turtle
ASKWITH [ condition ]
[  command(s) ]
tell turtles matching given condition to run commands given in the second list
returns result of last command run
note, after commands are run, currently active list of turtles returns to that set by the last TELL command (or default active turtle if TELL never given)
note, if more than one turtle is active, commands run return value associated with the last active turtle

Display Commands

Note, for commands below that receive/return an index number, that index should refer to a list of graphical items (like an image or color) whose items are clearly available in the GUI with their number or order apparent (so the user knows how to refer to them within a command). Also, it would be helpful to populate each list with some initial default choices for the user.

Command Description
SETBACKGROUND index
SETBG index
sets background color of screen to that represented by index
returns given index
SETPENCOLOR index
SETPC index
sets color of the pen to that represented by index
returns given index
SETPENSIZE pixels
SETPS pixels
sets size of the pen to be pixels thickness
returns given pixels
SETSHAPE index
SETSH index
sets shape of turtle to that represented by index
returns given index
SETPALETTE index r g b sets color corresponding at given index to given r g b color values
returns given index
note, color component values are nonnegative integers less than 256 specifying an amount of red, green, and blue
PENCOLOR
PC
returns turtle's current color index
SHAPE
SH
returns turtle's current shape index

Multiple Turtle Commands

Command Description
ID returns current active turtle's ID number
ID values typically start at 1 and increase by 1 with each new turtle created
note, there is technically only one "active turtle" at any given time since each command is run once for each active turtle, i.e., this value can always be used to identify the current turtle running the command
TURTLES

returns number of turtles created so far
TELL [ turtle(s) ] sets turtles that will follow commands hereafter
returns last value in turtles list
note, if turtle has not previously existed, it is created and placed at the home location
note, if more than one turtle is active, commands run return value associated with the last active turtle
ASK [ turtle(s) ]
[  command(s) ]
only the turtles given in first list all run commands given in the second list
returns result of last command run by the last turtle
note, after commands are run, currently active list of turtles returns to that set by the last TELL command (or default active turtle if TELL never given)
note, if more than one turtle is active, commands run return value associated with the last active turtle
ASKWITH [ condition ]
[  command(s) ]
tell turtles matching given condition to run commands given in the second list
returns result of last command run
note, after commands are run, currently active list of turtles returns to that set by the last TELL command (or default active turtle if TELL never given)
note, if more than one turtle is active, commands run return value associated with the last active turtle

Turtle Queries

Name Description
XCOR returns the turtle's X coordinate from the center of the screen
YCOR returns the turtle's Y coordinate from the center of the screen
HEADING returns the turtle's heading in degrees
PENDOWN?
PENDOWNP
returns 1 if turtle's pen is down, 0 if it is up
SHOWING?
SHOWINGP
returns 1 if turtle is showing, 0 if it is hiding

Math Operations

Name Description
SUM expr1 expr2
+ expr1 expr2
returns sum of the values of expr1 and expr2
DIFFERENCE expr1 expr2
- expr1 expr2
returns difference of the values of expr1 and expr2
PRODUCT expr1 expr2
* expr1 expr2
returns product of the values of expr1 and expr2
QUOTIENT expr1 expr2
/ expr1 expr2
returns quotient of the values of expr1 and expr2
REMAINDER expr1 expr2
% expr1 expr2
returns remainder on dividing the values of expr1 by expr2
MINUS expr
~ expr
returns negative of the values of expr
RANDOM max returns random non-negative number strictly less than max
SIN degrees returns sine of degrees
COS degrees return cosine of degrees
TAN degrees returns tangent of degrees
ATAN degrees returns arctangent of degrees
LOG expr returns natural log of expr
POW base exponent returns base raised to the power of the exponent
PI Reports the number Pi

Boolean Operations

Name Description
LESS? expr1 expr2
LESSP expr1 expr2
returns 1 if the value of expr1 is strictly less than the value of expr2, otherwise 0
GREATER? expr1 expr2
GREATERP expr1 expr2
returns 1 if the value of expr1 is strictly greater than the value of expr2, otherwise 0
EQUAL? expr1 expr2
EQUALP expr1 expr2
returns 1 if the value of expr1 and the value of expr2 are equal, otherwise 0
NOTEQUAL? expr1 expr2
NOTEQUALP expr1 expr2  
returns 1 if the value of expr1 and the value of expr2 are not equal, otherwise 0
AND test1 test2 returns 1 if test1 and test2 are non-zero, otherwise 0
OR test1 test2 returns 1 if test1 or test2 are non-zero, otherwise 0
NOT test returns 1 if test is 0 and 0 if test is non-zero

Variables, Control Structures, and User-Defined Commands

Name Description
MAKE variable expr
SET variable expr
assigns the value of expr to variable, creating the variable if necessary
returns expr
REPEAT expr [ command(s) ] runs command(s) given in the list the value of expr number of times
returns the value of the final command executed (or 0 if no commands are executed)
note, the value of the current iteration, starting at 1, is automatically assigned to the variable :repcount so that it can be accessed by the command(s)
DOTIMES [ variable limit ]
[ command(s) ]
runs command(s) for each value specified in the range, i.e., from (1 - limit) inclusive
returns the value of the final command executed (or 0 if no commands are executed)
note, variable is assigned to each succeeding value so that it can be accessed by the command(s)
FOR [ variable start end increment ]
[ command(s) ]
runs command(s) for each value specified in the range, i.e., from (start - end), going by increment
returns the value of the final command executed (or 0 if no commands are executed)
note, variable is assigned to each succeeding value so that it can be accessed by the command(s)
IF expr [ command(s) ] if expr is not 0, runs the command(s) given in the list
returns the value of the final command executed ( (or 0 if no commands are executed)
IFELSE expr
[ trueCommand(s) ]
[ falseCommand(s) ]
if expr is not 0, runs the trueCommands given in the first list, otherwise runs the falseCommands given in the second list
returns the value of the final command executed (or 0 if no commands are executed)
TO commandName
[ variable(s) ]
[ command(s) ]
assigns command(s) given in the second list to commandName using parameters given in first list as variables
when commandName is used later in a program, any given values are assigned to variables that can be accessed when the command list is run and the value of the final command executed is returned (or 0 if no commands are executed)
returns 1 if command is successfully defined, otherwise 0

Logistics

Team Members

  • Alex Boss
  • Hari Rajan
  • Belal Taher
  • Daniel Rubinstein

Time Taken

Date started: Feb 16

Date finished: Mar 10

Hours spent: 200+

About

Recreated environment for Logo - a popular children's coding language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •