Not Yet
Regression Tests
Go to English IDEMikayla'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
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
{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
"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
{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
{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
"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
{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
"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
"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
"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
"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
"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
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
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
25 print "T="#top # " M="#middle # " B="#bottom {test only}
{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
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|01\01"
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|02\02"
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/04\01"
if ix=74 let txt = "/03|07"
if ix=75 let txt = "/03|07/03"
if ix=76 let txt = "/03|07/03\03"
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/00\05_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
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}
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
"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
"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}
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
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
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
let x = "X"
let y = (x = "x")
let z = (x < "x")
print "x=" x ", y=" y ", z=" z
"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