Guess what.
I scrapped the Tetris project, and started programming on Logo instead.
...
Just kidding. I was struggling with my perfectionist attitude and getting nothing done, so I decided to take it easy, and re-learn a bit of those basics first.
I found this book from my bookshelf. It is called Logo I – Kilpikonnalla Tietotekniikkaan (rough translation: "Into computing with the Turtle"), and it's written by Aulis Puttonen and Marja-Liisa Vehkamäki. I can guess they are, or at least were teachers in our capital during the 80s.
The book was published in 1986 by a Helsinki based firm, Omput Oy.
I found this fascinating excercise, a game if you will, called Arvauspeli ("Guessing game"). Though really, it should be called a counting, memory, or even estimating game.
The idea is simple. Look at the screen and count the square tiles drawn as soon as you can, then answer when the game asks how many squares there are. If your answer is within the neighboring numbers, or a hit, you will be complemented on your accuracy.

Drawing the squares.

"How many squares did you see?"


"Nice estimate! The exact number is 5."

Front cover

Back cover
The back cover text, via Google translation (that's starting to look pretty good quality these days):
This book deals with the use of LOGO in Finnish education. The book gives an overview of the possibilities of the logo language as an aid for thinking and creative expression, as a developer of problem-solving skills, and as a programming language itself.
The reader is not required to have any previous knowledge of information technology, but the book offers plenty of stimulation even for those who are interested in the subject.

I guess these computers were high-end at the time. We didn't have Dandy computers in our school.
Google translation:
Middle school students are just as interested and motivated when moving the turtle on the screen, preparing instructions for stacks made of special sixes drawn in a cavalier's perspective, making brick boxes that contain, for example, alphabets made with the help of a villain, preparing larger pictorial entities, for example in the form of a cartoon or an animation, what would the falling of a brick look like, taking into account the laws of physics from the top of the stack or the entire stack falling over. The use of a coordinate system brings its own addition to the figures, which is greatly facilitated by its similarity to the coordinate system presented in math lessons. The origin is in the center of the image frame.
In addition, students are eager to learn Logo's list processing features.
The logo can be very well used, for example, as a support teaching tool in teaching concepts in middle school mathematics.

The code was for the Apple flavour Logo
The closest thing to Logo I have on my Linux computer is KTurtle. But it has a completely different dialect to the one on the early Apple computers.
I had to basically rewrite this whole thing from start to end. Oh, and I noticed I have tried doing this before on some earlier version of Logo years ago. I seem to have written my own little notes along the pages of the book.
On one of the previous pages I had written an important note for posterity:

Ready-made programs to modify.
So... I had a little weird feeling going about this. During the process, I also came to a realization that Kturtle kind of sucks, as it can only return one value to pass to another command. I would have needed at least two values for most of the parts of this game.
Also, the code was simply broken at places, I couldn't for the life of me figure out why $B = 100
, and then just stay that way through out the whole game. It just didn't make any sense. So I decided to use it in an IF
statement to compare the results and whether they were between 1 of the $realcount
(:A
in the original code).
I had to come up with quite a many workarounds, and they were simply messy.
Oh, and the X-Y coordinates were a bit off so I had to tweak them a bit too.
Okay. Well here's the resulting code. (I translated it into complete English so it is easier for everyone to read.)
The code
reset
sh
learn xvalue {
# Random X-position
$x = random 50,300
# print $x + "x"
return $x
}
learn yvalue {
# Random Y-position
$y = random 50,300
# print $y + "y"
return $y
}
learn setxy $x,$y{
# Set a starting position by the (random) values returned from xvalue and yvalue later.
gox $x
goy $y
}
learn square {
# wait 1/5 ## Use wait, if you want to be able to count the squares
# they are being drawn on the screen. The following repeat draws a
# simple predefined rectangle.
repeat 4 {
pd
forward 15
turnright 90
sh
}
}
learn picture {
$a = random 1,40
# The $a variable gets a random value between 1 and 40
# that determines how many squares will be printed on the screen.
# The repeat function will draw the squares at the coordinates from
# the random values derived from xvalue and yvalue.
repeat $a {
$x = xvalue
$y = yvalue
setxy $x,$y
square
}
return $a
}
learn estimate {
$realcount = picture ## Gets the return value from the picture command
wait 5 ## Change this value if you want to have more time to count the squares.
center
clear # Wipe the squares
$answer = ask "How many squares did you see?"
# Pass the answer to 'check' to be checked.
check $realcount,$answer
clear
}
learn check $realcount,$answer {
# Compare the anwer with the actual count of the squares:
if $answer < $realcount {
$b = $realcount - $answer
}
else {
$b = $answer - $realcount
}
if $b < 1.0 {
message "That's a good estimate! The real count is " + round ($realcount)
exit
}
message "Your answer " + $answer + " is wrong. The real count is " + round ($realcount)
}
# You'll need to evoke the 'estimate' command anywhere within the program
# to be able to run the game.
estimate