Biomathematicus

Science, Technology, Engineering, Art, Mathematics

Thinking of and working for the well being of the community, even through small efforts, can ripple for decades, perhaps centuries. I’m going to tell you a priceless story about it.

Rev. Saturnino Flor, Principal of Colegio Agustiniano Norte, Bogotá, Colombia, ca. 1975

In 1982, Agustinian Rev. Saturnino Flor, Principal of the school I was attending, Colegio Agustiniano Norte, Bogotá, Colombia, read in the news that personal computers were going to revolutionize the world. He did not want the kids in his community to be left behind. Thus, he organized a small fair, sold food and raffle tickets, and raised enough money in 1983 to buy 25 NEC APC computers, 64 kilobytes of memory.

Computer programming in BASIC became mandatory for all students from 6th grade till graduation from high school.  I wrote my first video game in BASIC in 1984 at age 11. It was my final project of the year, and it was not the best in the entire class. See the 1984 source code at the end, and a working Python translation.

My family was at the very low end of the middle class, flirting with poverty at the end of every month. Back then, a fifty-page magazine called “mi computer”, which was the serialized version of a ten-volume collection, was sold for 175 pesos, or 2 dollars (5 dollars today). It came out every week. I could buy only one, saving cents for months. But when I could finally open my new treasure, sometime in 1984, it changed my world. The second article that week was about artificial intelligence.

Fast forward four decades. I learned more, generated millions in research contracts, and trained dozens of students who are changing the world in their own ways.  I still use BASIC (VB.NET), mostly for nostalgia,  and I work every day with and in artificial intelligence.

Working for the community is the best investment of all.

Marcianitos


10 REM JUEGO CON SPRITE DE NAVE
20 REM PROYECTO FINAL
30 W=40:H=20
40 DIM PX(20),PY(20),OX(20),OY(20)
50 PC=0:OC=0:SC=0:G=0:F=0
60 BASE=1024

70 REM DEFINIR SPRITE SIMPLE
80 FOR I=0 TO 62:READ A:POKE 832+I,A:NEXT
90 DATA 0,24,0,60,0,126,0,255,0,24,0,24,0,24,0,24
100 DATA 24,60,126,255,126,60,24
110 FOR I=23 TO 62:POKE 832+I,0:NEXT

120 REM ACTIVAR SPRITE
130 POKE 2040,13
140 POKE 53269,1
150 POKE 53287,1

160 SX=160:SY=200

170 PRINT CHR$(147)

180 IF G=1 THEN 600

190 REM LIMPIAR AREA DE JUEGO
200 FOR I=0 TO 799:POKE BASE+I,32:NEXT

210 REM DIBUJAR PROYECTILES
220 FOR I=1 TO PC
230 IF PY(I)>=0 THEN POKE BASE+PY(I)*40+PX(I),81
240 NEXT

250 REM DIBUJAR OBJETOS
260 FOR I=1 TO OC
270 IF OY(I)>=0 THEN POKE BASE+OY(I)*40+OX(I),42
280 NEXT

290 PRINT TAB(0);"PUNTAJE ";SC

300 GET K$

310 IF K$="A" THEN SX=SX-4
320 IF K$="D" THEN SX=SX+4

330 IF SX320 THEN SX=320

350 POKE 53248,SX
360 POKE 53249,SY

370 REM DISPARO
380 IF K$=" " THEN PC=PC+1:PX(PC)=INT(SX/8):PY(PC)=H-2

390 REM MOVER PROYECTILES
400 FOR I=1 TO PC:PY(I)=PY(I)-1:NEXT

410 REM CONTROL DE CAIDA
420 F=F+1
430 IF F=H THEN G=1
466 NEXT

470 REM COLISIONES
480 FOR P=1 TO PC
490 FOR O=1 TO OC
500 IF PX(P)=OX(O) AND PY(P)=OY(O) THEN SC=SC+1:PY(P)=-1:OY(O)=-1
510 NEXT
520 NEXT

530 REM NUEVO OBJETO
540 IF RND(1)<.1 THEN OC=OC+1:OX(OC)=INT(RND(1)*40):OY(OC)=0

550 FOR T=1 TO 300:NEXT
560 GOTO 180

600 PRINT CHR$(147)
610 PRINT "FIN DEL JUEGO"
620 PRINT "PUNTAJE FINAL ";SC
630 END

import os
import random
import time
import msvcrt

# Set up game parameters
width = 40
height = 20
ship_x = width // 2
projectiles = []
falling_objects = []
score = 0
game_over = False
falling_speed_counter = 0

# Keypress handling
def get_key():
    if msvcrt.kbhit():
        key = msvcrt.getch()
        if key == b'\xe0':  # Special keys (arrows)
            return msvcrt.getch()  # Return the next byte (arrow key)
        return key
    return None

# Drawing the game state
def draw():
    os.system('cls')
    screen = [[" " for _ in range(width)] for _ in range(height)]
    
    # Draw the ship
    screen[height - 1][ship_x] = 'i'
    
    # Draw projectiles
    for x, y in projectiles:
        if y >= 0:
            screen[y][x] = 'O'
    
    # Draw falling objects
    for x, y, char in falling_objects:
        if y >= 0:
            screen[y][x] = char
    
    # Print the screen
    for row in screen:
        print("".join(row))
    
    # Print the score
    print(f"Puntaje: {score}")

# Updating the game state
def update():
    global projectiles, falling_objects, score, game_over, falling_speed_counter
    
    # Move projectiles
    new_projectiles = []
    for x, y in projectiles:
        y -= 1
        if y >= 0:
            new_projectiles.append((x, y))
    projectiles = new_projectiles
    
    # Control falling speed
    falling_speed_counter += 1
    if falling_speed_counter % 10 == 0:  # Move falling objects every 10th loop iteration
        falling_speed_counter = 0
        
        # Move falling objects
        new_falling_objects = []
        for x, y, char in falling_objects:
            y += 1
            if y < height:
                new_falling_objects.append((x, y, char))
            else:
                game_over = True  # Game over if any object hits the ground
        falling_objects = new_falling_objects
    
    # Check for collisions
    new_projectiles = []
    new_falling_objects = []
    for x, y in projectiles:
        hit = False
        for i, (ox, oy, char) in enumerate(falling_objects):
            if ox == x and oy == y:
                hit = True
                score += 1
                break
        if not hit:
            new_projectiles.append((x, y))
        else:
            falling_objects.pop(i)
    projectiles = new_projectiles
    
    # Add a new falling object
    if random.random() < 0.1:
        falling_objects.append((random.randint(0, width - 1), 0, chr(random.randint(65, 90))))

# Game loop
while not game_over:
    draw()
    update()
    
    # Handle user input
    key = get_key()
    if key:
        if key == b'M':  # Right arrow
            ship_x = min(width - 1, ship_x + 1)
        elif key == b'K':  # Left arrow
            ship_x = max(0, ship_x - 1)
        elif key == b' ':  # Spacebar to shoot
            projectiles.append((ship_x, height - 2))
    
    time.sleep(0.1)

print("Fin de Juego!")
print(f"Puntaje Final: {score}")