Outline: Add what I have so far

master
BodgeMaster 2022-11-05 05:35:52 +01:00
parent dff57cf324
commit 47fc6f5798
1 changed files with 266 additions and 0 deletions

266
outline.txt Normal file
View File

@ -0,0 +1,266 @@
This file contains materials I created to teach programming. It is more or less a precursor to ΛV.
Since then, I have decided to replace the A for the upwards-pointing cursor with a capital lambda.
ΛV will also only have one of each condition and use ! to negate them.
Prerequisite:
```
_______________
| |
| |
| |
| |
| |
| |
| |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
This needs to show up as a roughly square box.
1)
Lets start out by familiarizing ourselves with what things look like:
Cursor:
`< A > V`
Wall/barrier:
`| _ ¯ #`
Goal:
`$`
```
_______________
| # $# |
| # ###### |
|#### # |
| > # |
|###### |
| |
| |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Available instructions:
step
left
right
Possible solution: step step step left step step step right step step step step step
2)
Thats quite simple. But it can get tedious really quickly:
```
_______________
|V#$ |
| ############# |
| # # |
| # # |
| # # |
| ############# |
| |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Available instructions:
step
left
right
repeat<NUMBER>(INSTRUCTIONS)
Possible solution: repeat<6>(step) left repeat<14>(step) left repeat<6>(step) left repeat<12>(step)
3)
Same concept, different problem:
```
_______________
|>## |
| ## |
|# ## |
|## ## |
| ## ## |
| ## ## |
| ## $# |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Avaliable instructions:
step
left
right
repeat<NUMBER>(INSTRUCTIONS)
Possible solution: repeat<6>(right step left step)
4)
Now in actual programming, running code repeatedly is a bit different.
Instead of running a set number of times, which is certainly possible but
not always desired, they usually run as long as a certain condition is met.
This is called a loop. The most basic form it is known as a "while loop".
```
_______________
| |
| |
|############ |
|> $# |
|############ |
| |
| |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Available instructions:
step
left
right
while<CONDITION>(INSTRUCTIONS)
Available conditions:
facing wall
not facing wall
Possible solution: while<not facing wall>(step)
Additional practice:
```
_______________
| #$ # |
| ## # |
| # # |
| # # |
| # # |
| # # |
| #A# |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
5)
Lets turn this up a notch (copy+paste is gonna be real handy for this one):
```
_______________
| |
| ############# |
| #$# # |
| # # # |
| # # # |
| # ########### |
|A# |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Available instructions:
step
left
right
while<CONDITION>(INSTRUCTIONS)
Available conditions:
facing wall
not facing wall
Possible solution: while<not facing wall>(step) right while<not facing wall>(step) right while<not facing wall>(step) right while<not facing wall>(step) right while<not facing wall>(step)
6)
Loops can also be nested inside other loops:
```
_______________
| |
| ############# |
| # # |
| # ######### # |
| # #$ # |
| # ########### |
|A# |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Available instructions:
step
left
right
while<CONDITION>(INSTRUCTIONS)
Available conditions:
facing wall
not facing wall
goal reached
goal not reached
Possible solution: while<goal not reached>(while<not facing wall>(step) right)
7)
Weve already seen that conditions can be used to control loops. They can also be used to control if/else statements.
I am going to introduce a new item here:
`ó` apple
Pick up all the apples in the area.
You cannot use the "take" action when there is no apple to take.
```
_______________
| |
| |
| ##########|
| #$ ó ó <|
| ##########|
| |
| |
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Available instructions:
step
left
right
take
while<CONDITION>(INSTRUCTIONS)
if<CONDITION>(INSTRUCTIONS)
if<CONDITION>(INSTRUCTIONS) else(INSTRUCTIONS)
Available conditions:
facing wall
not facing wall
goal reached
goal not reached
on apple
not on apple
Possible solution: while<goal not reached>(if<on apple>(take) step)
8)
Lets do the same but more:
```
_______________
|ó $|
| ó ó |
| |
| ó |
| ó |
| ó ó |
|> ó ó|
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
Available instructions:
step
left
right
take
while<CONDITION>(INSTRUCTIONS)
if<CONDITION>(INSTRUCTIONS)
if<CONDITION>(INSTRUCTIONS) else(INSTRUCTIONS)
Available conditions:
facing wall
not facing wall
goal reached
goal not reached
on apple
not on apple
facing north
facing south
facing east
facing west
Possible solution: while<goal not reached>(if<on apple>(take) while<not facing wall>(step if<on apple>(take)) if<facing east>(left step left) else(right step right))