Tom's Kitchen Computer

(Regression Tests)

(Jump to "Kitchen Computer")

Contents

Not Yet
Regression Tests
Mikayla's PBJ -- (Clean) ->1 (->2)
PBJ Video Scripts (#2) (#3)
Tom's "Original PBJ" in Video
Tom's "Morning" in Video
Tom's "First Program"
Tom's Conditional PBJ (prior) PBJ ->4
Tom's Iterated PBJ ->5
Tom's Vars Experiments ->7
Tom's Calculator in Video
Tom's (Prior) Calculator ->8
Finished Calc ->12
Tom's Guessing Game ->13
Tom's RPS & Subroutines ->15/16/17/18
Tom's Seaman ->20
OCSTA Prep
Cleanup Test
Breakfast
Tom's TTT
Tom's Subroutines
No Assumes
Jam Tests
Variable Test
Round Test
Array Test
Substring Test
Go to English IDE
Go to Sandwich IDE


Regression Tests

These scripts can be used to verify that the Kitchen computer is functional. (Clean)

This first program has six errors, remove all six for it to run to completion:

let abc = 0 {each e! line should error..}
Do SubRtn
this aint no error {e!}
if abc then abc = 123 {e!}
open loaf {e!}
print "No errors" {remove all six to see this}

"SubRtn"
this aint no error {e!}
if abc then abc = 123 {e!}
open loaf {e!}
print "SR OK"
Done

{Mark's bugs}
print "Bgn"
Do Sub_Rtn
print "Back"

"Sub_Rtn"
print "inSub"
repeat 3 times
{whole-line comment}
print "midS"
Next
// nother comment
print "exit"
Done

print "out"
Done

PBJ Video Scripts

{setup}
see kitchen
open cabinet

{My original}
"Make Peanut Butter and Jelly Sandwich"
get stuff
put it together
done

{completed #1}

{added by student}
"Get Utensils"
get plate
get knife

{added in video}
"get ingredients"
get jam
get PB
get bread

"get stuff"
get ingredients
Get Utensils

{My original}
"Make Peanut Butter and Jelly Sandwich"
get stuff
put it together
done

PBJ Video #2 Script

{completed #1a}

"get ingredients"
open cabinet
get jam
get PB
get bread
done

"get stuff"
get ingredients
get tools
done

"get tools"
open cabinet
open drawer
get knife
get plate
done

"put it together"
Open PB
Open bread.
Open jam.
Get piece of bread.
Get piece of bread.
get jam on knife
Spread jam on bread.
get pb on knife
Spread PB on bread.
Put bread pieces together.
done

"make pbj"
get stuff
put it together
done

do make pbj

PBJ Video #3 Scripts

{original 3-line}
"Make PBJ"
get stuff
put it together

{added bag}
"Make PBJ"
get bag from drawer
get stuff
put it together
put sandwich in bag

{failed 3 copies}
"Make PBJ"
get bag from drawer
get stuff
put it together
put sandwich in bag
put it together
put sandwich in bag
put it together
put sandwich in bag

{added get loaf, failed again}
"Make PBJ"
get bag from drawer
get stuff
get loaf
put it together
put sandwich in bag
put it together
put sandwich in bag
put it together
put sandwich in bag

{use NoAssumes }

{as corrected w/repeat...}

"get ingredients"
open cabinet
get jam
get PB
get bread
Open PB
Open bread.
Open jam.
done

"get tools"
open cabinet
open drawer
get knife
get plate
get bag
done

"put it together"
Get piece of bread.
Get piece of bread.
get jam on knife
Spread jam on bread.
get pb on knife
Spread PB on bread.
Put bread pieces together.
done

"get stuff"
get ingredients
get tools
done

"Make PBJ"
get stuff
Repeat 3
put it together
put sandwich into bag
Next
done

do Make PBJ


Mikayla's PBJ

{added by student}
"get tools"
get plate
get knife

{added in video}
"get ingredients"
get jam
get PB
get bread

{Tom's enhancement}
"get stuff"
get ingredients
get tools

{Mikayla's original}
"make pbj"
get stuff
put it together

{TP added, won't run w/o this}
"put it together"
print "put it together"
done

Mikayla's Clean PBJ (no "Assume..")

make pbj

"get ingredients"
open cabinet
get bread
get jam
get PB
done

"get stuff"
get ingredients
get tools
done

"get tools"
open cabinet
open drawer
get knife
get plate
done

"put it together"
Open PB
Open bread.
Open jam.
Get piece of bread.
Get piece of bread.
get jam on knife
Spread jam on bread.
get pb on knife
Spread PB on bread.
Put bread pieces together.
done

"make pbj"
get stuff
put it together
done

Tom's "First Program" = Prep v#2

Open pantry cabinet.
Open other cabinet.
Open drawer.
Get knife
get plate
get bread
Open bread.
Get piece of bread.
get jam
Open jam
get jam on knife
spread jam on bread
Get another piece of bread.
get peanut butter
Open PB.
get PB on knife
spread PB on bread
Put bread pieces together.

(Longer Version)

Open pantry.
Open cupboard.
Open drawer.
Get peanut butter from pantry.
Get jam from pantry.
Get bread from pantry.
Get plate from cupboard.
Get knife from drawer.
Open jam.
Open PB.
Open bread.
Take first piece of bread out of package.
Put slice on plate.
Take second piece of bread out of package.
Put it on plate.
Get jam on knife
Spread jam on bread.
Get PB on knife
Spread PB on bread.
Put bread pieces together.
Close loaf.
Close jam.
Close peanut butter.
Put jam back.
Put PB back.
Put loaf back.
Put knife back.
get lunch bag
put sandwich into bag
Close cabinet.
Close cabinet.
Close drawer.
say "OK"

Tom's Vars Experiments

{All-in-One}
let A = 1+2*4-3/5

{Plus Alone}
let A=1
let B=2
let C=A+B
print "sum=" C

{Times Alone}
let A=1
let B=2
let C=A*B
print "product=" C

{Minus Alone}
let A=1
let B=2
let C=A-B
print "difference=" C

{Divide Alone}
let A=1
let B=2
let C=A/B
print "quotient=" C

Tom's "Original PBJ" in Video

{Make Peanut Butter & Jelly Sandwich}
Get stuff
Put it together

Tom's "Morning" in Video

"EatBreakfast"
Get stuff out
Pour stuff
Eat it
Done

"MakeLunch"
get stuff
put stuff together
Done

"InKitchen"
Do EatBreakfast
Do MakeLunch
Put stuff away
Done

"BednBath"
Print "Do whatever you need to do in B&B"
Done

"GoToSchool"
Print "Do whatever you need to do to leave for school"
Done

"Morning"
Do BednBath
Do InKitchen
Do GoToSchool
Done

Do Morning

Tom's (Previous) "Original PBJ" in Video as Corrected

get bread from pantry
get plate from cabinet
Get knife from drawer.
get peanut butter
get jam
Open jam.
Open PB.
Open bread.
Get slice of bread.
Get another slice of bread.
spread jam
spread PB
Put bread pieces together.

Tom's Conditional PBJ {finished v#2}

Open pantry cabinet.
if it is Monday get grape
if it is Tuesday get peach
any other day get strawberry
get peanut butter
Open other cabinet.
Open drawer.
get bread from pantry
get plate from cabinet
Open bread.
Get piece of bread.
Get knife from drawer.
Open jam
Open PB
get jam on knife
spread jam on bread
Get piece of bread.
get PB on knife
spread PB on bread
Put bread pieces together

Tom's Iterated PBJ {finished v#3}

get bag from drawer
get bread from pantry
get plate from cabinet
Get knife from drawer.
get peanut butter
get jam
Open jam.
Open PB.
Open bread.
repeat 3
Get slice of bread.
Get another slice of bread.
spread jam
spread PB
Put bread pieces together.
put sandwich into bag
next

PBJ (with conditions)

1 Open cabinet
2 If it's Saturday take the Strawberry jam
3 If it's Sunday take the Peach
4 any other day take grape jelly
5 Grab Peanut Butter
6 Take out Bread
7 Open Jam
8 Open Peanut Butter
9 Open Bread
10 Open other cabinet
11 Take out plate
12 Open drawer
13 Take out knife
14 Take first piece of bread out of package
15 Put on plate
16 Take second piece of bread out of package
17 Put on plate
18 Spread jam on bread
19 Spread Peanut Butter on bread
20 Put bread pieces together

PBJ (in button)

1 Open cabinet
2 Take out Jam
3 Take out PB
4 Take out Bread
5 Open Jam
6 Open PB
7 Open Bread
8 Open other cabinet
9 Take out plate
10 Open drawer
11 Take out knife
12 Take first piece of bread out of package
13 Put on plate
14 Take second piece of bread out of package
15 Put on plate
16 Spread jam on bread
17 Spread PB on bread
18 Put bread pieces together

Tom's Calculator (in video)

"Calculator"
{Four inputs}
Print "Input your first number:"
Input first
Print "What do you want to do (* - * /)?"
Input operator,1
Print "Input the number to do it with:"
Input second
Print "Input ="
{Input equal}
If operator = "+" then
Let result = ____ {1st+2nd}
{do other operators similarly}
Display "The result is " the result

Tom's Better Calculator (in video)

"Any Calculation"
{Two inputs}
Print "What do you want to do (* - * / Q)?"
Input operator,1
If operator = "Q" then Stop
Print "Input the number to do it with:"
Input second
Print "Input ="
{Input equal}
If operator = "+" then
Let result = ____ {1st+2nd}
{do other operators similarly}
Display "The result is " the result
Done

"Calculator"
{First calculation}
Print "Input your first number:"
Input first
Do Any Calculation
Repeat
{Additional calculations}
Put result in first
Do Any Calculation
If operator = "Q" then Exit
Next
Done

Tom's (Prior) Calculator (in video, before iter)

"Any Calculation"
{Two inputs}
Input operator,1
Input second
{Do the operation}
If operator = "+" then
Let result = first+second
If operator = "-" then
Let result = first-second
If operator = "*" then
Let result = first*second
If operator = "/" then
Let result = first/second
Display the result

"Calculator"
{First calculation}
Input first
Do Any Calculation
Stop {unless you want it to do two calcs}
{Additional calculations}
Let first = result
Do Any Calculation

Finished Calc

"Any Calculation"
Print "What do you want to do (+ - * / =)?"
Input operator,1
if operator = 'Q' then Exit
if operator = '=' then Exit
Print "Input the number to do it with:"
Input second
box result
If operator = "+" then
Let result = first + second
If operator = "-" then
Let result = first - second
If operator = "*" then
Let result = first * second
If operator = "/" then
Let result = first / second
done

"Calculator"
Print "Input your first number:"
Input first
Repeat forever
do Any Calculation
if operator = 'Q' then Stop
Print "result: "# result
Let first = result
next
done

do Calculator

(Pre-Prior) Calculator

Input result
Repeat
Input operator
Input number
If the operator is a '+' then
Add number to result
Display result
Next iteration

(Prior) Calculator

1 Variable result = 0
2 Repeat
3 Show "The result is: " result
4 Show "Type a command: (C)lear, (A)dd,"
5 Show "..(S)ubtract, (M)ultiply, (D)ivide:"
6 Input operation 1
7 Input value -1
8 If the operation is "C" then
9 let result = value
10 If the operation is "A" then
11 let result = result + value
12 If the operation is "S" then
13 let result = result - value
14 If the operation is "M" then
15 let result = result * value
16 If the operation is "D" then
17 let result = result / value
18 Next repeat

Cleanup Test

Open cabinet
Open cabinet
Open drawer
Open fridge
get knife
get fork
get spoon
get milk
get plate
get cereal
get loaf
get jam
get PB
put plate back
Open milk
Open jam
Open jam
Open cereal
Open loaf
close cereal
close loaf
close jam
close milk
put milk away
put jam into fridge
put loaf in cabinet
put PB back in drawer
put cereal away
put knife away
put fork in drawer
put spoon back in cabinet
close drawer
close fridge
close cabinet
close cabinet

Breakfast (in button)

1 Remove milk from fridge
2 Remove cereal from cabinet
3 Take out spoon from drawer
4 Remove bowl from cabinet
5 Pour cereal into bowl
6 Pour milk into bowl
7 Dip spoon into bowl
8 Lift spoon to mouth
9 Eat
10 See if bowl is empty
11 If not, do it again.

Steve's Improved Breakfast

Remove milk from fridge
Remove cereal from cabinet
Take out spoon from drawer
Remove bowl from cabinet
Pour cereal into bowl
pour milk into bowl
Repeat the following steps:
Dip spoon into bowl
Lift spoon to mouth
Eat
See if bowl is empty
If not, do this iteration again

Alt Breakfast

1 Remove milk from fridge
2 Remove cereal from cabinet
3 Take out spoon from drawer
4 Remove bowl from cabinet
5 Pour cereal into bowl
6 Pour milk into bowl
7 Repeat
8 Dip spoon into bowl
9 Lift spoon to mouth
10 Eat
11 See if bowl is empty
12 If so, get out
13 Next

Tom's Newer RPS

{RPS TDD.17}
do RPS

"won"
print "won"
let sco = 0
if humplay = 'R' if complay = 'R' let sco = 0
if humplay = 'P' if complay = 'P' let sco = 0
if humplay = 'S' if complay = 'S' let sco = 0
if humplay = 'R' if complay = 'P' let sco = -1
if humplay = 'R' if complay = 'S' let sco = 1
if humplay = 'P' if complay = 'R' let sco = 1
if humplay = 'P' if complay = 'S' let sco = -1
if humplay = 'S' if complay = 'P' let sco = 1
if humplay = 'S' if complay = 'R' let sco = -1
if sco < 0 print "I win"
if sco> 0 print "you win"
otherwise print "tie"
done

"RPS"
pump
play
won
done

"score"
print "score"
do won
done

"play"
print "play"
input humplay,1
random num<3
let complay = "RPS"
character complay,num,1
let coply = complay
let huply = humplay
print "I play " coply " you play " huply
done

"pump"
print "pump"
wait 0.1 sec
print "2.."
delay 0.2 sec
print "3.."
done

{RPS TDD.13}
"RPS"
wave hand while thinking about play {not think}
score {Other..first}
show play {Again} {sooner}

"RPS"
wave hand 3* times {punct}
play, more {punct}
score... {OK?}

{RPS TDD.15}
do RPS

"RPS"
wave hand 3 times
play more
score
done

"wave hand 3 times"
print "wave hand 3* times" {sb punct}
wait 0.5 sec
print "2.."
delay 0.2 sec
print "3.."
nother pump
done

"score"
print "score..." {sb punct}
done

"play more"
print "play, more" {sb punct}
{see show}
done

"nother pump"
print "nother pump"
done

"see show"
print "see show"
done

{RPS TDD.OK}
"RPS" {OK}
pump hand
show play
score

"pump hand"
print "wave hand"
wait 1 sec
print "while thinking"
delay 1 sec
print "about play"
done

"score"
print "score"
let sco = 0
if humplay = 'R' if complay = 'R' let sco = 0
if humplay = 'R' if complay = 'P' let sco = -1
if humplay = 'R' if complay = 'S' let sco = 1
if humplay = 'P' if complay = 'R' let sco = 1
if humplay = 'P' if complay = 'S' let sco = -1
if humplay = 'S' if complay = 'P' let sco = 1
if humplay = 'S' if complay = 'R' let sco = -1
if sco < 0 print "I win"
if sco> 0 print "you win"
otherwise print "tie"
done

"show play"
print "show play"
input humplay,1
random num<3
let complay = "RPS"
character complay,num,1
let coply = complay
let huply = humplay
print "I play " coply " you play " huply
done

Tom's RPS & Subroutines

{This also is the example code for Subroutines)

Let how = 0 {or -1=Ternary, or +1=Numerical}

"DecideWinner"
if how=0 then do Score6ifs
if how>0 then do Score10h
if how<0 then do ScoreTern
AnnounceWinner
Done

"AnnounceWinner"
if score>0 Print "You win"
if score<0 Print "I win"
otherwise Print "Tie"
Done

"OneRPSplay"
Synchronization
PresentPlays
DecideWinner
Done

"Synchronization"
Print "One"
Wait 1 second
Print "Two"
Wait 1 second
Print "Three"
Done

"PresentPlays"
Variable HumPlay
Variable myPlay
Random r < 3
if r=0 then Let myPlay = "R"
if r=1 then Let myPlay = "P"
Otherwise Let myPlay = "S"
Input HumPlay,1
Print "I played " myPlay ", you played " HumPlay Done
Done

"Score6ifs"
let score = 0
if myPlay = "R" then if HumPlay = "P" then let score = 1
if myPlay = "R" then if HumPlay = "S" then let score = -1
if myPlay = "P" then if HumPlay = "R" then let score = -1
if myPlay = "P" then if HumPlay = "S" then let score = 1
if myPlay = "S" then if HumPlay = "P" then let score = -1
if myPlay = "S" then if HumPlay = "R" then let score = 1
print "(Score6)=" score
Done

"Score10h"
let h = 0
if HumPlay = "P" then let h = 1
if HumPlay = "S" then let h = 2
let score = h*10+r {r is still 0/1/2 from the random calc}
let mid = score
if score=01 then let score = -1 {h=rock, r=paper, comp wins}
if score=10 then let score = 1 {r=rock, h=paper, hum wins}
if score=12 then let score = -1 {h=paper, r=scis, comp wins}
if score=21 then let score = 1
if score=02 then let score = 1
if score=20 then let score = -1
otherwise let score = 0 {00 or 11 or 22 = tie}
print "(Score10)=" score "/" mid
Done

"ScoreTern"
let score = 0
if HumPlay = "R" then let score = -1
if HumPlay = "S" then let score = 1
let score = score-(r-1)
let mid = score
if score*score=4 then let score = -score/2
print "(Score3)=" score "/" mid
Done

Repeat
OneRPSplay
Next

Tom's (Earlier) RPS

{added code in green, diagnostic code in red, subroutines Score6ifs/Score10h/ScoreTern to select scoring method}

Repeat
Print out "One"
Wait 1 second
Print out "Two"
Wait 1 second
Print out "Three"
{decide what to play}
Variable myPlay = "S"
Random r < 3
if r=0 then Let myPlay = "R"
if r=1 then Let myPlay = "P"
print "(" myPlay ")"
Input HumPlay,1
Print "I played " myPlay ", you played " HumPlay
{compare plays}
Score6ifs {Score6ifs/Score10h/ScoreTern}
{announce winner}
if score>0 Print "You win"
if score<0 Print "I win"
otherwise Print "Tie"
Next

"Score6ifs"
let score = 0
if myPlay = "R" then if HumPlay = "P" then let score = 1
if myPlay = "R" then if HumPlay = "S" then let score = -1
if myPlay = "P" then if HumPlay = "R" then let score = -1
if myPlay = "P" then if HumPlay = "S" then let score = 1
if myPlay = "S" then if HumPlay = "P" then let score = -1
if myPlay = "S" then if HumPlay = "R" then let score = 1
print "(Score6)=" score
done

"Score10h"
let h = 0
if HumPlay = "P" then let h = 1
if HumPlay = "S" then let h = 2
let score = h*10+r {r is still 0/1/2 from the random calc}
let mid = score
if score=01 then let score = -1 {h=rock, r=paper, comp wins}
if score=10 then let score = 1 {r=rock, h=paper, hum wins}
if score=12 then let score = -1 {h=paper, r=scis, comp wins}
if score=21 then let score = 1
if score=02 then let score = 1
if score=20 then let score = -1
otherwise let score = 0 {00 or 11 or 22 = tie}
print "(Score10)=" score "/" mid
done

"ScoreTern"
let score = 0
if HumPlay = "R" then let score = -1
if HumPlay = "S" then let score = 1
let score = score-(r-1)
let mid = score
if score*score=4 then let score = -score/2
print "(Score3)=" score "/" mid
done

Prior RPS

Print "We are playing Rock-Paper-Scissors"
Print "(more stuff) [#2]"
iterate {each round}
Print "One..."
Wait 1 second
Print "Two..."
Wait 1 second
Print "Three..."
{calculate comPlay..}
Variable now = the seconds
let temp = now/3
Whole temp
let comPlay = now-3*temp
Input humPlay 1
if humPlay = "Q" then exit
if humPlay = "R" then let temp = 0
if humPlay = "P" then let temp = 3
if humPlay = "S" then let temp = 6
if temp>6 exit
let temp = comPlay+temp {calculate & print score}
if temp=0 Print "We both got rock"
if temp=4 Print "We both got paper"
if temp=8 Print "We both got scissors"
if temp=1 Print "My paper covers your rock"
if temp=3 Print "Your paper covers my rock"
if temp=2 Print "Your rock breaks my scissors"
if temp=6 Print "My rock breaks your scissors"
if temp=5 Print "My scissors cuts your paper"
if temp=7 Print "Your scissors cuts my paper"
Next repeat

Partial RPS

Print "We are playing Rock-Paper-Scissors"
Print "(more stuff) [partial #1]"
iterate {each round}
Print "One..."
Wait 1 second
Print "Two..."
Wait 1 second
Print "Three..."
{calculate comPlay}
Input humPlay
{calculate score}
Print "(score)"
Next repeat

Tom's (full) Guessing Game

1 Say 'Hi.'
2 Say 'We are going to play the Guessing Game.'
3 Say 'You think of a number between 1 and 99,'
4 Say 'then I will ask some yes/no questions,'
5 Say 'then I will tell you your number.'
6 Say 'Press enter when you think of a number.'
7 Input answer
8 Say "OK, let's go"
9 let top = 100
10 let bottom = 1
11 Iterate
12 Variable middle = (top+bottom)/2
13 round middle
14 Say "Is your number less than " # middle # "? (y/n)"
15 Input answer 1
16 Say " "
17 if answer = "Y" then
18 let top = middle
19 if answer = "N"
20 let bottom = middle
21 if bottom+1 = top exit
22 Next iteration
23 Say 'The number you thought of is ' # bottom

Tom's (mini) Guessing Game

1 Say 'Hi.'
2 Say 'Press enter after you pick a number for me to guess.'
3 Input
4 let top = 100
5 let bottom = 1
6 Iterate
7 Variable middle = (top+bottom)/2
8 round middle
9 Say "Is your number less than " # middle # "? (y/n)"
10 Input answer 1
11 if answer = "Y" then
12 let top = middle
13 if answer = "N" then
14 let bottom = middle
15 if bottom+1 = top exit
16 Next iteration
20 Say 'The number you thought of is ' # bottom

25 print "T="#top # " M="#middle # " B="#bottom {test only}


Tom's (TDD Video) Seaman

{preload Seaman..}
Let PreGuess = "AEIONMLKJH"
Array myWord = 'H','E','L','L','O'
Array gWord = '_','_','_','_','_'
Let posn = 5

{Seaman TDD.18}
"Part 2"
Print dashes and letters
Input letter
Decide if input is correct
{Print whole picture <- example error}
{Do Print Seaman}
done

"Play Seaman"
Part 1
repeat
Part 2
next
done

"Part 1"
Print instructions
Input whole word
Hide word from 2nd player
done

{Seaman +methods.20}
"Print instructions"
Print "This is Seaman, yada, yada"
Done

"Input whole word"
Array myWord
Array gWord
Variable posn
Print "Enter your word"
if posn = 0 then Repeat 1 {-- else use preload --}
Let posn = 0
Repeat
Input guess,1
If guess < 'A' then Exit
Add 1 to posn
Let item posn of myWord = guess
Let item posn of gWord = "_"
Next
Next
Print myWord " is " posn " letters. " gWord
Done

"Hide word from 2nd player"
Repeat 25
Print " "
Next
Done

"Print dashes and letters"
Print gWord " (" nerrs " misses)"
If gottem=posn then Stop
If nerrs=6 then Stop
Done

"Input letter"
character guess=PreGuess,0
if guess> " " then
substring PreGuess,1,33
otherwise
Input guess,1
Print "Got " guess
Done

--------------------------------------------------------------------------------

{Seaman scoring.21}

Variable nerrs = 0
Variable gottem = 0

"Decide if input is correct"
Let try = 0
Let got = 0
Repeat posn
Add 1 to try
if myWord[try]=guess then Do ItsEqual
Next
if got = 0 then Do UnEqual
{Do Print Seaman}
Done

"ItsEqual"
Let item try of gWord = guess
Add 1 to gottem
Add 1 to got
Done

"UnEqual"
Add 1 to nerrs
Done

--------------------------------------------------------------------------------

{Seaman indexed arrays.22}

"Print Seaman"
{Calculate index for body parts}
Let bp = 0
If nerrs>0 then Let bp = Sinx[nerrs]
Let lino = 1
Repeat 12 {the total number of lines to print}
{Build aLine = boat line # body part line}
Let aLine = pLines[lino]
Let bx = 0
if bp>0 then Let bx = Sinx[bp+lino-1]
if lino<10 then if bx>0 then
Let aLine = aLine # pLines[bx]
Print aLine
Add 1 to lino
Next
Done

Let nerrs = 6 {test this subroutine, omit otherwise...}
InitAryz {Do Missing Lines also?}
Do Print Seaman {Do Play Seaman instead}

"InitAryz"
Array pLines
Let pLines[1] = " /|"
Let pLines[2] = " / |"
...
Let pLines[9] = "/________|"
Let pLines[10] = " |"
Let pLines[11] = "______________________"
Let pLines[12] = "\ /"
Let pLines[13] = " _ "
Let pLines[14] = " ( )"
Let pLines[15] = " | "
Let pLines[16] = " _|_"
Let pLines[17] = " / | "
Let pLines[18] = " / | \"
...
Let pLines[23] = " / "
Let pLines[24] = " / \"
Let pLines[25] = " _/ "
Let pLines[26] = " _/ \_"
Array Sinx = 8,17,26,35,44,53,62
Let Sinx[8] = 0 {top of (no) head, nerrs=1}
Let Sinx[9] = 0 {(no) face, nerrs=1}
Let Sinx[10] = 0 {(no) neck, nerrs=1}
Let Sinx[11] = 0
Let Sinx[12] = 0
Let Sinx[13] = 0 {(no) waist, nerrs=1}
Let Sinx[14] = 21 {1 thigh, nerrs=1}
Let Sinx[15] = 23 {1 knee, nerrs=1}
Let Sinx[16] = 25 {1 foot, nerrs=1}
Let Sinx[17] = 0 {top of (no) head, nerrs=2}
Let Sinx[18] = 0 {(no) face, nerrs=2}
Let Sinx[19] = 0
Let Sinx[20] = 0
Let Sinx[21] = 0 {no spine no hands, nerrs=2}
Let Sinx[22] = 0 {(no) waist, nerrs=2}
Let Sinx[23] = 22
Let Sinx[24] = 24 {2 knees, nerrs=2}
Let Sinx[25] = 26 {2 feet, nerrs=2}
Let Sinx[26] = 0 {top of (no) head, nerrs=3}
Let Sinx[27] = 0 {(no) face, nerrs=3}
Let Sinx[28] = 15 {neck, nerrs=3}
Let Sinx[29] = 15
Let Sinx[30] = 15 {spine no hands, nerrs=3}
Let Sinx[31] = 15 {waist, nerrs=3}
Let Sinx[32] = 22
Let Sinx[33] = 24
Let Sinx[34] = 26 {2 feet, nerrs=3}
Let Sinx[35] = 0 {top of (no) head, nerrs=4}
...
Let Sinx[52] = 26 {2 feet, nerrs=5}
Let Sinx[53] = 13 {top of head, nerrs=6}
Let Sinx[54] = 14 {face, nerrs=6}
Let Sinx[55] = 16 {neck, nerrs=6}
Let Sinx[56] = 18
Let Sinx[57] = 20 {spine+hands, nerrs=6}
Let Sinx[58] = 15 {waist, nerrs=6}
Let Sinx[59] = 22
Let Sinx[60] = 24
Let Sinx[61] = 26 {2 feet, nerrs=6}
Done

"Missing Lines"
Let pLines[3] = " / |"
Let pLines[4] = " / |"
Let pLines[5] = " / |"
Let pLines[6] = " / |"
Let pLines[7] = " / |"
Let pLines[8] = " / |"
Let pLines[19] = " / | "
Let pLines[20] = " / | \"
Let pLines[21] = " / "
Let pLines[22] = " / \"
...
Let Sinx[36] = 0 {(no) face, nerrs=4}
Let Sinx[37] = 16 {neck, nerrs=4}
Let Sinx[38] = 17
Let Sinx[39] = 19 {spine+1 hand, nerrs=4}
Let Sinx[40] = 15 {waist, nerrs=4}
Let Sinx[41] = 22
Let Sinx[42] = 24
Let Sinx[43] = 26 {2 feet, nerrs=4}
Let Sinx[44] = 0 {top of (no) head, nerrs=5}
Let Sinx[45] = 0 {(no) face, nerrs=5}
Let Sinx[46] = 16 {neck, nerrs=5}
Let Sinx[47] = 18
Let Sinx[48] = 20 {spine+hands, nerrs=5}
Let Sinx[49] = 15 {waist, nerrs=5}
Let Sinx[50] = 22
Let Sinx[51] = 24 {2 knees, nerrs=5}
Let Sinx[63] = 0
Done


Tom's (Previous Video) Seaman

{I did three different implementations of ASCII graphics, in separate subroutines..}
{..NoGraf/Simple/IxGraf/RunLx, so they are easy to switch out for separate testing.}
{The table lookup is very slow, so I inserted some fake iterations (in red) to speed it up some.}
{There's also some test code (in red) so I could let it run unattended.}

Let theWord = "" {or "HELLO"}
Let guessWd = "" {or "_____"}
Let nLets = 0 {or 5}
Let sofar = 0
Let nerrs = 0
if nLets=0 Repeat
Input letter 1
If letter < "A" then Exit
Let theWord = theWord # letter
Let guessWd = guessWd # "_"
Add 1 to nLets
Next
print "[Got '" theWord "']"
let cheat = "" {or theWord or "UVWXYZ"}
Repeat 33 {to clear screen}
Print " "
Next
Repeat
NoGraf {or Simple or IxGraf or RunLx}
Print guessWd " e=" nerrs
if nerrs>5 exit
if sofar=nLets exit
Character letter = cheat
Substring cheat,1,9
if letter<"A" Input letter,1
Let nuly = ""
Let offs = 0
Let seen = 0
Repeat nLets
Character looky = theWord,offs
Character prio = guessWd,offs
Add 1 to offs
if looky=letter then Add 1 to seen
Otherwise Let looky = prio
Let nuly = nuly # looky
Next
Let guessWd = nuly
If seen>0 then add seen to sofar {score match}
If seen=0 then add 1 to nerrs {score no-match}
Next
if nerrs>6 print "Too bad"
if sofar=nLets print "You got it"

"NoGraf"
Print " "
Done

"Simple"
if nerrs>5 Print " /| _"
else Print " /|"
if nerrs>5 Print " / | ( )"
else Print " / |"
if nerrs>4 Print " / | _|_"
else if nerrs>3 Print " / | _|"
else if nerrs>2 Print " / | |"
else Print " / |"
if nerrs>4 Print " / | / | \"
else if nerrs>3 Print " / | / |"
else if nerrs>2 Print " / | |"
else Print " / |"
if nerrs>4 Print " / | / | \"
else if nerrs>3 Print " / | / |"
else if nerrs>2 Print " / | |"
else Print " / |"
if nerrs>2 Print " / | |"
else Print " / |"
if nerrs>1 Print " / | / \"
else if nerrs>0 Print " / | /"
else Print " / |"
if nerrs>1 Print " / | / \"
else if nerrs>0 Print " / | /"
else Print " / |"
if nerrs>1 Print " /________| _/ \_"
else if nerrs>0 Print " /________| _/"
else Print " /________|"
Print " ______________________"
Print " \ /"
Done

"IxGraf"
let ro = 0
Repeat 11
add 1 to ro
let ix = ro
IxTxt
let line = txt
let txt = ""
if nerrs>0 if ro<10 repeat 1
let ix = ro+30
IxTxt
Substring ix = txt,nerrs*2,2
IxTxt
Next
print line txt
Next
Done

"IxTxt"
let txt = ""
repeat 1
if ix<38 repeat 1
if ix<20 repeat 1
if ix<5 repeat 1
if ix=1 let txt = " /|"
if ix=2 let txt = " / |"
if ix=3 let txt = " / |"
if ix=4 let txt = " / |"
Next
if ix<5 exit
if ix<10 repeat 1
if ix=5 let txt = " / |"
if ix=6 let txt = " / |"
if ix=7 let txt = " / |"
if ix=8 let txt = " / |"
if ix=9 let txt = " /________|"
Next
if ix<10 exit
if ix<15 repeat 1
if ix=10 let txt = " ______________________"
if ix=11 let txt = " \ /"
if ix=12 let txt = " |"
if ix=13 let txt = " _"
if ix=14 let txt = " ( )"
Next
if ix<15 exit
if ix=15 let txt = " _|"
if ix=16 let txt = " _|_"
if ix=17 let txt = " / |"
if ix=18 let txt = " / | \"
if ix=19 let txt = " / |"
Next
if ix<20 exit
if ix<24 repeat 1
if ix=20 let txt = " / | \"
if ix=21 let txt = " /"
if ix=22 let txt = " / \"
if ix=23 let txt = " /"
Next
if ix<24 exit
if ix<33 repeat 1
if ix=24 let txt = " / \"
if ix=25 let txt = " _/"
if ix=26 let txt = " _/ \_"
if ix=31 let txt = " 0 0 0 0 0 013"
if ix=32 let txt = " 0 0 0 0 0 014"
Next
if ix<33 exit
if ix=33 let txt = " 0 0 012151616"
if ix=34 let txt = " 0 0 012171818"
if ix=35 let txt = " 0 0 012192020"
if ix=36 let txt = " 0 0 012121212"
if ix=37 let txt = " 0212222222222"
Next
if ix<38 exit
if ix<63 repeat 1
if ix<43 repeat 1
if ix=38 let txt = " 0232424242424"
if ix=39 let txt = " 0252626262626"
if ix=41 let txt = "53535353535354"
if ix=42 let txt = "55555555555556"
Next
if ix<43 exit
if ix<48 repeat 1
if ix=43 let txt = "57575758596060"
if ix=44 let txt = "61616162636464"
if ix=45 let txt = "65656566676868"
if ix=46 let txt = "69696970707070"
if ix=47 let txt = "71727373737373"
Next
if ix<48 exit
if ix<53 repeat 1
if ix=48 let txt = "74757676767676"
if ix=49 let txt = "77787979797979"
if ix=50 let txt = "80808080808080"
if ix=51 let txt = "81818181818181"
if ix=52 let txt = "82828282828282"
Next
if ix<53 exit
if ix<58 repeat 1
if ix=53 let txt = "/10|00"
if ix=54 let txt = "/10|00_05"
if ix=55 let txt = "/09|01"
if ix=56 let txt = "/09|01(04)01"
if ix=57 let txt = "/08|02"
Next
if ix<58 exit
if ix=58 let txt = "/08|02|05"
if ix=59 let txt = "/08|02_04|00"
if ix=60 let txt = "/08|02_04|00_00"
if ix=61 let txt = "/07|03"
if ix=62 let txt = "/07|03|05"
Next
if ix<63 exit
if ix<68 repeat 1
if ix=63 let txt = "/07|03/03|01"
if ix=64 let txt = "/07|03/03|0101円"
if ix=65 let txt = "/06|04"
if ix=66 let txt = "/06|04|05"
if ix=67 let txt = "/06|04/02|02"
Next
if ix<68 exit
if ix<73 repeat 1
if ix=68 let txt = "/06|04/02|0202円"
if ix=69 let txt = "/05|05"
if ix=70 let txt = "/05|05|05"
if ix=71 let txt = "/04|06"
if ix=72 let txt = "/04|06/04"
Next
if ix<73 exit
if ix<78 repeat 1
if ix=73 let txt = "/04|06/0401円"
if ix=74 let txt = "/03|07"
if ix=75 let txt = "/03|07/03"
if ix=76 let txt = "/03|07/0303円"
if ix=77 let txt = "/02_48|00"
Next
if ix<78 exit
if ix=78 let txt = "/02_48|00_01/00"
if ix=79 let txt = "/02_48|00_01/0005円_00"
if ix=80 let txt = "_02_61"
if ix=81 let txt = "02円/20"
if ix=82 let txt = "~66"
Next
Done

"RunLx"
variable ch
let ro = 0
Repeat 12 {lines}
let line = ""
add 1 to ro
let ix = ro+40
IxTxt
Substring ix = txt,nerrs*2,2
IxTxt
Repeat {runs}
Character ch = txt
if ch = "" exit
Character ix = txt,1,2
Substring txt,3,99
let word = ch # ch # ch # ch
if ix>40 Repeat {solid}
if ix<42 exit
if ix<45 let word = ch
else let ix = ix-3
let line = line # word
let ix = ix-1
Next {solid}
let word = " "
if ix<40 Repeat {spcs}
if ix<1 exit
if ix<5 let word = " "
else let ix = ix-3
let line = line # word
let ix = ix-1
Next {spcs}
let line = line # ch
Next {runs}
print line
Next {lines}
Done

Prior Seaman Play

1 print "Your Seaman word is already in.."
2 let lx = 5
3 let word = "HELLO" {this should be an array}
4 let sho = " _ _ _ _ _" {this should be an array}
5 {startup code omitted...}
14 let sofar = lx {= unguessed}
15 let wrong = 0 {= guessed wrong}
16 repeat {as many times as needed}
17 print sho concatenate " .. errs = " wrong
18 if sofar = 0 exit
19 input guess 1
20 if guess < "A" exit
21 if guess> "Z" exit
22 let nx = 0
23 let gotit = false
24 repeat lx {try each letter}
25 {*letter = nx`th item of array word*} substring letter = word,nx
26 let zx = 0
27 if letter = guess then {*do all this..*} repeat 1
28 let gotit = true
29 {*stub to replace letter..*} let zx = nx*2+1
30 {*lft = left end of sho*} substring lft = sho,0,zx
31 {*rit = right end of sho*} substring rit = sho,zx+1,lx*2-zx
32 let sho = lft guess rit {*..to here*}
33 let sofar = sofar-1
34 {*end of letter=guess*} next
35 let nx = nx+1
36 next {try next letter}
37 if gotit = false then let wrong = wrong+1
38 if wrong> 7 exit
39 next {as many times as needed}
40 if sofar = 0 print "You got it!"
41 if wrong> 7 print "Better luck next time"

Tom's Seaman Entry (whole word)

1 print "This is Seaman_1word, type your word.." {#1}
2 let sho = ""
3 input word
4 let lx = 0
5 repeat
6 {*letter = lx`th item of array word*} substring letter = word,lx
7 { print "[" lx " = " letter "]" }
8 if letter < "A" exit
9 let lx = lx+1
10 next
11 repeat lx {lx is now the length of word}
12 let sho = sho " _"
13 next
14 print lx concatenate sho
15 variable letter

Tom's Seaman Entry (1 letter at a time)

1 print "This is Seaman, type the letters of your word.." {#2}
2 let word = "" {this should be an array}
3 let sho = "" {this should be an array}
4 let lx = 0
5 repeat
6 input letter 1
7 if letter < "A" exit
8 let lx = lx+1
9 let word = word concatenate letter {insert in array}
10 next
11 repeat lx
12 let sho = sho " _"
13 next
14 print lx concatenate sho
15 variable letter

OCSTA Prep

{Tab3=PBJ}

open cabinet
get jam
get PB
get bread
get plate
get knife
put it together

{Tab4=Cond}

open cabinet
if it is Tuesday get grape
if it is Thursday get peach
any other day get Strawberry
get PB
get bread
get plate from other cupbd
get knife from drawer
open bread
put it together

{Tab5=Rpt}

it is Monday
open cabinet
if it is Tuesday get grape
if it is Thursday get peach
any other day get Strawberry
get PB
get bread
get plate from other cupbd
get knife from drawer
get bag
open bread
open PB
open jam
repeat 3
put it together
put sandwich in bag

{Tab6=Vars}

1 box Begin is 2
2 box AddMe is 3
3 box Sum
4 let Sum be Begin +4 + AddMe
5 print "the sum is " Sum

{Tab7=Calc}

input first
input plus
input second
input equal
let result = first + second
display result

{Tab8=FullC}

print "Enter a number"
input result
repeat
print "Enter an operator (+ - * /)"
input operator,1
if operator = "Q" then exit
print "Enter a number"
input number
if operator = "+" then
let result = result + number
if operator = "-" then
let result = result - number
if operator = "*" then
let result = result * number
if operator = "/" then
let result = result / number
print "The result is " # result
next

{Tab9=TDD}

"Make a PBJ"
Get stuff
Put it together

"Get stuff"
Get Ingredients
Get utensils

"Get Ingredients"
{filled in by student}
get jam
get PB
get bread

"Get utensils"
{filled in by student}
get plate
get knife

"Put it together"
{filled in by student}
...

{2022 July 23}


Tom's TTT

This is incredibly slow, so I usually run it in full-auto mode, where the digits of variable auto are the X plays (and also the O plays in score-only mode, see comment on first line), then I go away and do something else while it runs.

let auto = 0 {=574 for PlayO win, 123467895 if score only}
Variable noisy = false
Variable who = "X"
Variable board = "0123456789"
Variable Xwon = false
Variable Owon = false
Repeat 10
Do ShowBoard
If Xwon then Exit
If Owon then Exit
Do OnePlay
If who = "X" then Let who = "O"
otherwise Let who = "X"
Next
If Xwon then Print "X won"
If Owon then Print "O won"
Otherwise Print "Cat's"

"ShowBoard"
Variable here = 0
repeat 3 {rows}
let line = ""
repeat 3 {cols}
add 1 to here
if line> "" let line = line # " | "
Character info = board,here
let line = line # info
next
print line
if here<9 print "--+---+--"
next
Done

"OnePlay"
let play = 0
let doing = 0
if who="O" do PlayO {test: who="Z" for score only}
if play=0 if auto>0 repeat 1
Character play = auto,0
Substring auto,1,9
Print who # " played " # play
Next
if play=0 Repeat
Print "Input " # who # " play"
Input play,1
Let prio = 0
if play>9 then Let play = 0
if play>0 then
Character prio = board,play
if prio>9 then Let play = 0
if play>0 if prio>0 then Exit
Next
Substring left = board,0,play
Substring right = board,play+1,9
Let board = left # who # right
If doing=0 then Repeat 1
Let doing = play
Do CountMarks
If Wsum<99 then Exit
If who = "X" then Let Xwon = true
If who = "O" then Let Owon = true
Next
Done {end of OnePlay}

"CountMarks"
Let Wsum = 0
Let nxt = 0
Let all8 = "123,456,789,147,258,369,159,357"
Repeat 8
Substring run = all8,nxt,3
Let ran = run
Add 4 to nxt
Let psum = 0
Let osum = 0
Let ok = false
Repeat 3
Character sqr = run,0
Character tmp = board,sqr
if sqr=doing then Let ok = true
Substring run,1,3
if tmp=who Add 1 to psum
if tmp=ohw Add 1 to osum
Next
If not ok then Again
If noisy print who "+" doing " " ran " (" ok ") " psum "/" osum " = " Wsum
If psum=3 then add 99 to Wsum {same as before}
If Wsum>90 then Exit
If play>0 then Again {win test only}
If psum=2 then add 70 to Wsum
If osum=2 then add 15 to Wsum
If psum+osum=0 then add 1 to Wsum
If osum>0 If psum=0 then add 2 to Wsum
If psum>0 If osum=0 then add 3 to Wsum
Next
Done

"PlayO"
Let best = 0
Let hiScore = 0
Let doing = 0
Let ohw = "X"
if who = "X" then Let ohw = "O"
Repeat 9
add 1 to doing
Character tmp = board,doing
if tmp>"A" then Again
Do CountMarks
If noisy print ".. = " Wsum " : " hiScore " => " best
if Wsum<hiScore then Again
Let hiScore = Wsum
Let best = doing
Next
Let play = best
if hiScore>60 then If who = "O" then Let Owon = true
Print who # " played " # play
Done

--------------------------------------------------------------------------------

{prior TTT}
Initialize board
let turns = 0
let auto = 0 {=578 for PlayO win, 123467895 if score only cats}
Repeat
Show current board
if turns>8, exit
if turns>4 do Test for win
If won, exit
let turns = turns+1
if who = "X" let who = "O"
otherwise let who = "X"
print "input for " who
Repeat
let play = 0
if who="O" do PlayO {who="Z" for score only}
if play=0 if auto>0 repeat 1
Character play = auto,0
Substring auto,1,9
Next
if play=0 Input play -1
Round play
if play<1 do it again
if play>9 do it again
Character tmp = board,play
if tmp<"A" exit
Next
Update board
Next
If won, Say who " won"
otherwise say "Cat's"

"PlayO"
print "Play" who
let doing = 0
let sofar = 0
let best = 0
let whom = "B"
repeat 9
let doing = doing+1
Character tmp = board,doing
if tmp>"A" do it again
let score = 0
let all8 = "123,456,789,147,258,369,159,357"
repeat 8
Substring prms = all8,0,3
Substring all8,4,33
CountMarks
if rez=0 let score = score+1 {open}
if Wsum=2 let score = score+70 {win}
otherwise let score = score+Wsum*2
if Zsum=2 let score = score+15 {block}
otherwise let score = score+Zsum*3
if score>66 exit
Next
if score>sofar repeat 1
let best = doing
let sofar = score
print "so far " best " + " score
Next
Next
let play = best
Done

"CountMarks"
let doit = false
Character tmp = prms,0
Character first = board,tmp
if tmp=doing let doit = true
Character tmp = prms,1
Character mid = board,tmp
if tmp=doing let doit = true
Character tmp = prms,2
Character last = board,tmp
if tmp=doing let doit = true
let rez = -1
let Xsum = 0
let Osum = 0
if doit repeat 3
let info = first
if info="X" let Xsum = Xsum+1
if info="O" let Osum = Osum+1
let first = mid
let mid = last
Next
if doit let rez = Xsum*4+Osum
if turns>6 let doit = false
if whom = "X" let rez = Xsum {rez is returned result}
if whom = "O" let rez = Osum
let Wsum = Osum
if who = "X" let Wsum = Xsum {Wsum is the player's sum}
let Zsum = Osum
if who = "O" let Zsum = Xsum {Zsum is the opponent's sum}
if doit print "CM " who " " prms " x=" Xsum " o=" Osum
Done

"Initialize board"
print "Initialize board"
let who = "O"
let won = false
let board = "0123456789"
let turns = 0
Done

"Show current board"
print "Show current board"
Variable step = 0
Repeat 3
let line = ""
let cols = 0
Repeat 3
let step = step+1
let cols = cols+1
Character square = board,step
let line = line # " " # square # " "
if cols<3 let line = line # "|"
Next
Show line
if step<9 Show "---+---+---"
Next
Done

"Update board"
print "Update board: " who " => [" play "]"
Substring frnt = board,0,play
Substring back = board,play+1,9
put frnt # who # back into board
Done

"Test for win"
print "Test for win"
Repeat 1
let prms = 123
ThreeInaRow
if won exit
let prms = 456
ThreeInaRow
if won exit
let prms = 789
ThreeInaRow
if won exit
let prms = 147
ThreeInaRow
if won exit
let prms = 258
ThreeInaRow
if won exit
let prms = 369
ThreeInaRow
if won exit
let prms = 159
ThreeInaRow
if won exit
let prms = 357
ThreeInaRow
Next
Done

"ThreeInaRow"
let won = false
Character tmp = prms,0
Character first = board,tmp
Character tmp = prms,1
Character mid = board,tmp
Character tmp = prms,2
Character last = board,tmp
if first=who if mid=who if last=who let won = true
print "3iaRo " prms " = '" first "/" mid "/" last " = " who "/" won
Done

No Assumes

{Source: Mikayla Maki}

"get tools"
open cabinet
open drawer
get knife
get plate
get bag
done

"get ingredients"
open cabinet
get jam
get PB
get bread
done

"put it together"
Open PB
Open bread.
Open jam.
Get piece of bread.
Get piece of bread.
get jam on knife
Spread jam on bread.
get pb on knife
Spread PB on bread.
Put bread pieces together.
done

"get stuff"
get ingredients
get tools
done

"Make PBJ"
get stuff
put it together
put sandwich into bag
done

do Make PBJ

Tom's Subroutines

"Morning":
Get up
Breakfast
Make lunch
Go to School
(done)

"Breakfast":
(We already have this one, back there)
Remove milk from fridge
Remove cereal from cabinet
Take out spoon from drawer
print "Oops, can't do bowl & plate in same program"
{Remove bowl from cabinet}
{Pour cereal into bowl}
{Pour milk into bowl}
{Repeat}
{ Dip spoon into bowl}
{ Lift spoon to mouth}
{ Eat}
{ See if bowl is empty}
{ If so, exit.}
{ Next}

"Make lunch":
(We already have most of this one, back there)
(...just put the sandwich in a bag)
Open cabinet
If it's Saturday take the Strawberry jam
If it's Sunday take the Marmalade
any other day take grape jelly
Take out PB
Take out Bread
Open Jam
Open PB
Open Bread
Open other cabinet
Take out plate
Open drawer
Take out knife
Take first piece of bread out of package
Put on plate
Take second piece of bread out of package
Put on plate
Spread jam on bread
Spread PB on bread
Put bread pieces together
print "Don't have a bag to put it in"

"Go to School":
(Do you think you can do this one?)
(There's a small part back there,)
(but it won't run in Kitchen, so...)
print "Went to school"

"Get up":
(I don't know about this one, maybe you should write it ;-)
print "Got up"

do Morning {this runs the whole program}

Simple Subroutines

{collapse line 14 into 13 for a separate test; delete line 15 for ditto}
1 do part1
2 part2
3 do part2 (again)

5 "part2"
6 msg "x=" # x
7 if x>23 then
14 add 2 to x
8 let x=x+1
9 done

11 "part1"
15 break
12 let x=23
13 done


Jam Tests

1 get marmalade from cabinet
2 get jelly
3 get PB
4 get peach
5 dump

it is Tuesday
Open pantry cabinet.
if it is Monday get grape
if it is Tuesday get peach
any other day get strawberry
Open jam
close jam
put jam away

Variable Test (Video)

1 box Begin is 2
2 box AddMe is 3
3 box Sum {no value specified}
4 let Sum be Begin +4 + AddMe
5 print "the sum is " Sum

Variable Test (Prior)

1 Let myVar = 12 {try also =2}
2 Variable calc = myVar*3+27-60 {=3}
3 if calc=3 repeat 1
4 msg "Do this first"
5 if myVar < calc exit {change < to> for 3rd try}
6 msg "then this, but not if myVar is less than 3"
7 msg "none of this happens if calc is not equal to 3"
8 next (done: repeat and conditional are both finished)
9 msg "happens immediately if first condition is false"

Round Test

1 let a=5
2 let b=5.499
3 let c= 5.5
4 let d = 5.501
5 let e = 6
6 let u = 6.499
7 let v = 6.5
8 let w = 6.501
9 let x =5.999
11 round a
12 round b
13 round c
14 round d
15 round e
16 round u
17 round v
18 round w
19 whole x
20 print "= " # x # " " # a # " " # b # " / " # c # " " # d # " " # e # " " # u # " " # v # " / " # w
21 print 'sb: = 5 5 5 / 6 6 6 6 6 / 7'

Array Test

{BubbleSort = Array Test}
List shopping = "Bread","Meat","Veggies","Ice cream"
Print shopping
Let shopping[2] = "--Tofu"

Let SortMe = shopping
Let Nitems = 4
Do BubbleSort
Print SortMe
...
"BubbleSort"
Let fini = 1
Repeat Nitems-1
Let here = 1
Let none = true
Repeat Nitems-fini
Let tmp = SortMe item here
Let nxt = item here+1 of SortMe
If tmp> nxt then Do Xchange
Add 1 to here
Next
If none then Exit
Add 1 to fini
Next
Done
"Xchange"
Let item here of SortMe = nxt
Let SortMe item here+1 = tmp
Let none = false
Done

Substring Test

variable abc = "abcdefghijklmnopqrstuvwxyz"
let num = 88/5
substring xyz = abc,3,7
substring uvw = abc,5
substring def = abc,-num,2
substring abc,num,num
print "x='" xyz "' u='" uvw "' d='" def "' a='" abc "'"
dump

Go to Kitchen computer



Not Yet...

These programs need to work, but don't yet (I'm still working out the bugs) or are untested...

let x = "X"
let y = (x = "x")
let z = (x < "x")
print "x=" x ", y=" y ", z=" z

Date Test

1 it is Tuesday {change it to make the condition fail}
2 print year # "/" # month # "/" # date
3 if it is tuesday
4 input xzy
5 what day is it
6 if it is less than xzy print it # " < " # xzy
7 otherwise print it # "> " # xzy

Time Test

1 print the time
2 what is the seconds
3 wait 4 seconds
4 print "seconds = " # it
5 get the date # " " # time
6 put it into abc
7 print abc
8 variable abc

Anything Else (fails)

Open cabinet
If it's Saturday choose the Strawberry jam
If it's Sunday, choose the Peach
If it's any other day then choose Grape
(do the rest of the program)

Anything Else, Fixed (OK)

Open cabinet
If it's Saturday take the Strawberry jam
If it's Sunday, take the Peach
If it's any other day then take Grape
(do the rest of the program)

Rock-Paper-Scissors

Repeat (as many times as you want)
Repeat 3 times
Pound fist on open hand (to synchronize timing) [probably can't do it in Kitchen]
Wait one second
Open fist (into flat hand (paper), or two-finger "V" (scissors), or else leave it fist (rock) = output)
Look at other player's hand = input [probably can't do it in Kitchen]
Decide who won (rock breaks scissors, scissors cuts paper, paper covers rock)
Count and show the score = output
Go back for another round

Tom's Subroutines

"Morning":
Get up
Breakfast
Make lunch
Go to School
(done)

"Breakfast":
(We already have this one, back there)
(...but Kitchen doesn't like bowls & plates in same program)

"Make lunch":
(We already have most of this one, back there)
(...just put the sandwich in a bag)

"Go to School": [probably can't do it in Kitchen]
(Do you think you can do this one? There's a small part back there)

"Get up": [probably can't do it in Kitchen]
(I don't know about this one, maybe you should write it ;-)


[2022 September 12a] -- Tom's Java

AltStyle によって変換されたページ (->オリジナル) /