Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 47
» Latest member: Shed_Grill
» Forum threads: 313
» Forum posts: 2,245

Full Statistics

Online Users
There are currently 61 online users.
» 0 Member(s) | 59 Guest(s)
Applebot, Bing

Latest Threads
I bought a PicoCalc
Forum: Everything else
Last Post: johnno56
Today, 12:39 AM
» Replies: 1
» Views: 16
Gorn vs Spock
Forum: Programming
Last Post: aurel
Yesterday, 05:58 PM
» Replies: 1
» Views: 279
Galaga7
Forum: NaaLaa 7 Code
Last Post: aurel
01-12-2026, 10:20 PM
» Replies: 3
» Views: 338
Connect 4
Forum: NaaLaa 7 Code
Last Post: Marcus
01-12-2026, 06:37 PM
» Replies: 7
» Views: 350
Any chance of writing a t...
Forum: Suggestions
Last Post: luwal
01-11-2026, 07:49 AM
» Replies: 7
» Views: 1,822
DeepCoin in micro(A)
Forum: Programming
Last Post: aurel
01-10-2026, 08:56 AM
» Replies: 16
» Views: 342
Tic-Tac-Toe
Forum: NaaLaa 7 Code
Last Post: johnno56
01-07-2026, 07:58 AM
» Replies: 4
» Views: 779
Jam for All Basic Dialect...
Forum: Programming
Last Post: luwal
01-06-2026, 11:40 PM
» Replies: 28
» Views: 1,302
Happy New Year
Forum: Everything else
Last Post: aurel
01-05-2026, 10:24 AM
» Replies: 5
» Views: 1,087
Compile an n7 file from t...
Forum: NaaLaa 7 Questions
Last Post: kevin
01-04-2026, 12:45 PM
» Replies: 2
» Views: 150

 
Photo I bought a PicoCalc
Posted by: indru91112 - Yesterday, 09:53 PM - Forum: Everything else - Replies (1)

I ordered a PicoCalc in November. After a brief wait and lots of emails to customs, I finally got it delivered today! I booted it up with PicoMite MMBASIC gave me serious nostalgia, reminding me of my first programming adventures with BASIC back in the day...

Anyway, I messed around with the device and just wrote a simple circle-drawing thingy...

[Image: IMG-6717.png]

(Yeah yeah that's me on the reflection Big Grin)

Lots of adventures coming up with my small friend

Print this item

  Gorn vs Spock
Posted by: aurel - 01-11-2026, 06:19 PM - Forum: Programming - Replies (1)

Oh no Gorn ...noooo ...

[youtube]gTfyvj7FmSQ[/youtube]

Print this item

  Galaga7
Posted by: aurel - 01-11-2026, 03:28 PM - Forum: NaaLaa 7 Code - Replies (3)

I have naalaa7 and in repo is a Galaga7.n7 program
but this one not work

error:
i can not  'copy' error from message box from ned editor
it is something about xform is not declared ?
where ?

Code:
constant ECOLS = 12, EROWS = 8

visible plyImg, enm1Img, enm2Img, enm3Img, enm4Img

set window "Attackers", 256, 224, false, 3
set redraw off

CreateAssets()

randomize 2
enms = dim(ECOLS, EROWS)
for y = 1 to 5  for x = 0 to ECOLS/2 - 1
    if rnd(4) > 0
        select rnd(4)
            case 0
                img = enm1Img
                stm = 1
            case 1
                img = enm2Img
                stm = 2
            case 2
                img = enm3Img
                stm = 3
            default
                img = enm4Img
                stm = 4               
        endsel
        e = [
                img: img,
                a: 0,
                stm: stm,
                pos: Point(0, 0),
                size: Point(14, 14),
                c: fill(Point(0, 0), 4),
                p: unset]
    else
        e = unset
    endif
    enms[x][y] = e
    enms[ECOLS - 1 - x][y] = copy(e)
next

enmsa = 0
divet = 120
tmp = []

enmbullets = []
enmshoott = 180

ply = []
ply.pos = Point(120, 200)
ply.size = Point(16, 16)
ply.spd = 1
plybullets = []

while not keydown(KEY_ESCAPE, true)
    i = 0
    while i < sizeof(plybullets)
        b = plybullets[i]
        b.pos.x = b.pos.x + b.spd.x
        b.pos.y = b.pos.y + b.spd.y
        if b.pos.x < -b.size.x or b.pos.x >= 256 or b.pos.y < -b.size.y or b.pos.y >= 224
            free key plybullets, i           
        else
            hit = false
            for y = EROWS - 1 to 0
                for x = 0 to ECOLS - 1
                    e = enms[x][y]
                    if e and Collides(b, e)
                        e.stm = e.stm - 1
                        if e.stm <= 0  enms[x][y] = unset
                        hit = true
                        break
                    endif
                next
                if hit  break
            next
            if hit  free key plybullets, i
            else  i = i + 1
        endif
    wend
   
    i = 0
    while i < sizeof(enmbullets)
        b = enmbullets[i]
        b.pos.x = b.pos.x + b.spd.x
        b.pos.y = b.pos.y + b.spd.y
        if b.pos.x < -b.size.x or b.pos.x >= 256 or b.pos.y < -b.size.y or b.pos.y >= 224
            free key enmbullets, i           
        else
            i = i + 1
        endif
    wend


    if keydown(KEY_LEFT)  ply.pos.x = max(ply.pos.x - ply.spd, 0)
    if keydown(KEY_RIGHT)  ply.pos.x = min(ply.pos.x + ply.spd, 240)
    if keydown(KEY_SPACE, true)
        plybullets[sizeof(plybullets)] = [
                pos: Point(ply.pos.x + ply.size.x/2 - 1, ply.pos.y - 4),
                size: Point(2, 4),
                spd: Point(0, -4)]
    endif

    divet = divet - 1
    if divet <= 0
        clear tmp
        for y = 0 to EROWS - 1  for x = 0 to ECOLS - 1
            if enms[x][y] and enms[x][y].p = unset  tmp[sizeof(tmp)] = enms[x][y]
        next
        if sizeof(tmp)
            e = tmp[rnd(sizeof(tmp))]
            e.p = 0
            e.c[0].x = e.pos.x; e.c[0].y = e.pos.y
            e.c[1].x = rnd(242); e.c[1].y = 224
            e.c[2].x = rnd(242); e.c[2].y = 224
            e.c[3].x = e.pos.x; e.c[3].y = e.pos.y
            divet = 120 + rnd(3)*60
        else
            divet = 60
        endif
    endif
   
    enmshoott = enmshoott - 1
    if enmshoott < 0
        enmshoott = 180 + rnd(3)*60
        clear tmp
        for y = 0 to EROWS - 1  for x = 0 to ECOLS - 1
            if enms[x][y]  for i = 0 to enms[x][y].p <> unset  tmp[sizeof(tmp)] = enms[x][y]
        next
        if sizeof(tmp)
            e = tmp[rnd(sizeof(tmp))]
            dx = ply.pos.x - e.pos.x
            dy = ply.pos.y - e.pos.y
            k = sqr(dx*dx + dy*dy)
            if k > 0
                dx = 2*dx/k
                dy = 2*dy/k
                enmbullets[sizeof(enmbullets)] = [
                        pos: Point(e.pos.x + e.size.x/2 - 2, e.pos.y + e.size.y/2 - 2),
                        size: Point(4, 4),
                        spd: Point(dx, dy)]
            endif
        endif
    endif

    enmsa = (enmsa + 1)%360
    for y = 0 to EROWS - 1
        offsx = 128 - ECOLS*8 + sin(rad(enmsa + y*22.5))*24
        offsy = 24
        for x = 0 to ECOLS - 1
            e = enms[x][y]
            if e
                gx = x*16 + offsx + 1; gy = y*16 + offsy + 1
                if typeof(e.p)
                    e.p = e.p + 0.005
                    if e.p >= 1
                        e.p = unset
                        e.pos.x = gx; e.pos.y = gy
                    else
                        e.c[3].x = gx; e.c[3].y = gy
                        EvalCBCD(e.pos, e.c, e.p)
                        e.a = atan2(e.pos.y, e.pos.x) - 0.5*PI
                        if e.p < 0.2  e.a = e.a*5*e.p
                        elseif e.p >= 0.8  e.a = e.a*(1 - e.p)/0.2
                        EvalCBC(e.pos, e.c, e.p)
                    endif
                else
                    e.pos.x = gx
                    e.pos.y = gy
                endif
            endif
        next
    next
   
    set color 0, 0, 0
    cls
    set color 255, 255, 255
    for y = 0 to EROWS - 1  for x = 0 to ECOLS - 1
        e = enms[x][y]
        if e and e.p = unset draw image e.img, e.pos.x, e.pos.y
    next
    for y = 0 to EROWS - 1  for x = 0 to ECOLS - 1
        e = enms[x][y]
        if e and typeof(e.p)
            draw image xform e.img, e.pos.x + 7, e.pos.y + 7, 1, 1, e.a, 7, 7
        endif
    next
    draw image plyImg, ply.pos.x, ply.pos.y
    set color 255, 255, 255
    foreach b in plybullets  draw rect b.pos.x, b.pos.y, b.size.x, b.size.y, true
    set color 0, 255, 255
    foreach b in enmbullets  draw rect b.pos.x, b.pos.y, b.size.x, b.size.y, true

    set color 255, 255, 255
    set caret 0, 0
    wln sizeof(plybullets)
    wln sizeof(enmbullets)
   
    redraw
    fwait 60
wend

function Point(x, y)
    return [x: x, y: y]
endfunc

function EvalCBC(dst, curve, param)
    b0 = (1 - param)^3
    b1 = 3*(1 - param)^2*param
    b2 = 3*(1 - param)*param^2
    b3 = param^3
    dst.x = b0*curve[0].x + b1*curve[1].x + b2*curve[2].x + b3*curve[3].x
    dst.y = b0*curve[0].y + b1*curve[1].y + b2*curve[2].y + b3*curve[3].y
endfunc

function EvalCBCD(dst, curve, param)
    b0 = 3*(1 - param)^2
    b1 = 6*(1 - param)*param
    b2 = 3*param^2
    dst.x = b0*(curve[1].x - curve[0].x) + b1*(curve[2].x - curve[1].x) + b2*(curve[3].x - curve[2].x)
    dst.y = b0*(curve[1].y - curve[0].y) + b1*(curve[2].y - curve[1].y) + b2*(curve[3].y - curve[2].y)
endfunc

function Collides(a, b)
    return a.pos.x + a.size.x > b.pos.x and a.pos.x < b.pos.x + b.size.x and
            a.pos.y + a.size.y > b.pos.y and a.pos.y < b.pos.y + b.size.y
endfunc

function CreateAssets()
    plyImg = CreateBitmap(
            [[0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0],
            [0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0],
            [0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0],
            [1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1],
            [1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1],
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
            [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1],
            [1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1],
            [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
            255, 255, 255)
    enm1Img = CreateBitmap(
            [[0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
            [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
            [0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0],
            [1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1],
            [1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1],
            [1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1],
            [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
            [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
            [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
            [0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0],
            [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0],
            [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0]],
            255, 224, 0)
    enm2Img = CreateBitmap(
            [[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0],
            [1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1],
            [1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1],
            [1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1],
            [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1],
            [1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1],
            [1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1],
            [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
            [0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0],
            [0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0],
            [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
            [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
            [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
            [0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0]],
            255, 96, 0)
    enm3Img = CreateBitmap(
            [[0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0],
            [0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0],
            [0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0],
            [0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0],
            [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
            [0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0],
            [0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0],
            [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
            [0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0],
            [1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1],
            [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
            [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0],
            [0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0],
            [0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0]],
            0, 128, 255)
    enm4Img = CreateBitmap(
            [[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0],
            [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
            [1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1],
            [1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1],
            [1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1],
            [1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1],
            [0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0],
            [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0],
            [0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0],
            [0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0],
            [0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0],
            [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1],
            [1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
            [0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0]],
            128, 0, 255)
endfunc

function CreateBitmap(data, r, g, b)
    img = createimage(sizeof(data[0]), sizeof(data))
    set image img
    for y = 0 to sizeof(data) - 1  for x = 0 to sizeof(data[0]) - 1
        set color data[y][x]*r, data[y][x]*g, data[y][x]*b
        set pixel x, y
    next
    set image primary
    set image colorkey img, 0, 0, 0
    return img
endfunc

Print this item

  Connect 4
Posted by: 1micha.elok - 01-11-2026, 05:24 AM - Forum: NaaLaa 7 Code - Replies (7)

CONNECT 4
 - Be the first player to get 4 of your chips in a row horizontally, vertically, or diagonally
 - Connect 4 was invented by  Howard Wexler and Ned Strongin in 1974
-  It's a text based game, no graphics, no GUI, just an old classic terminal style game

 Note :
 Behold "asm...endasm" is in the program Smile

Code:
'===========================================
'
' CONNECT 4 - ALMOST UNBEATABLE VERSION
' - Be the first player to get
'   4 of your chips in a row 
'   horizontally, vertically, or diagonally
' - Connect 4 was invented by
'   Howard Wexler and Ned Strongin
'   in 1974
'
' Note :
' Behold "asm...endasm" is in the program :)
'
'============================================

' constant
constant ROWS = 6      ' indices 0 to 5
constant COLS = 7      ' indices 0 to 6
constant CONNECT = 4

' Global board(row, col)
visible board = dim(ROWS, COLS)
visible turn

pln "CONNECT FOUR - Human (X) vs Computer (O)"
InitBoard()

turn = 0  ' Computer starts first
printBoard()


'-----------
' MAIN loop
'-----------
do
    if turn = 1 then
        ' Human's turn
        pln
        write "Your move - Enter column (1 to "+ COLS+ "): "; cmd = rln(1,TYPE_NUMBER)
        colInput = cmd

        if colInput >= 1 and colInput <= COLS then
            col0 = colInput - 1
            if IsValidMove(col0) then
                PlaceChip(1, col0)
                pln "You placed in column "+ colInput
                wait 2000
                printBoard()
                turn = 0  
            else
                pln "Column is full! Try another."
            endif
        else
            pln "Invalid column. Enter 1 to "+ COLS
        endif
    else
        ' Computer's turn
        write "Computer is thinking..."
        wait 300
        AITurn()
        printBoard()
        turn = 1
    endif

    ' Check win/draw
    if CheckWinInColumn(1, -1) then
        pln "You win! Congratulations!"
        ' mimic a gosub to label AskReplay
        asm
            move @0 AskReplay:
            call @0
        endasm
    elseif CheckWinInColumn(2, -1) then
        pln "Computer wins! Better luck next time."
        ' mimic a gosub to label AskReplay
        asm
            move @0 AskReplay:
            call @0
        endasm
    elseif BoardFull() then
        pln "It's a draw!"
        ' mimic a gosub to label AskReplay
        asm
            move @0 AskReplay:
            call @0
        endasm
    endif
loop

'sub-routine
asm
    AskReplay:
endasm
do
    write "Play again? (Y/N)"; again = rln(1,TYPE_STRING)
    pln
until upper(again)="Y" or upper(again)="N"
if upper(again) = "Y" then
    again = "n"
    InitBoard()
    turn = 0  ' Computer starts again
    printBoard()
    ' return to whereever we were called from.
    asm
        ret
    endasm
else
    pln "Thanks for playing! Goodbye!"
    pln
    system("pause")
    end
endif



' -----------------------------
'  functions
' -----------------------------
function InitBoard()
    for r = 0 to ROWS - 1
        for c = 0 to COLS - 1
            board[r][c] = 0
        next
    next
endfunc

function printBoard()
    pln
    pln
    for r = 0 to ROWS - 1
        for c = 0 to COLS - 1
            chip = " "
            if board[r][c] = 1 then chip = "X"
            if board[r][c] = 2 then chip = "O"
            write "["+ chip+ "]"
        next
        pln
    next
    for c = 0 to COLS - 1
        write " "+ (c + 1) + " "
    next
    pln
endfunc

function IsValidMove (col)
    return (board[0][col] = 0)
endfunc

function PlaceChip (player, col)
    for r = ROWS - 1 to 0 step -1
        if board[r][col] = 0 then
            board[r][col] = player
            break
        endif
    next
endfunc

' Returns the row where a chip would land in column 'col'
function GetDropRow(col)
    for r = ROWS - 1 to 0 step -1
        if board[r][col] = 0 then
            return r
        endif
    next
    return -1
endfunc

' col = -1 ? full board check; else simulate move in col
function CheckWinInColumn (player, col)
    if col = -1 then
        for r = 0 to ROWS - 1
            for c = 0 to COLS - 1
                if board[r][c] = player then
                    if CheckPattern(player, r, c) then
                        return 1
                        break
                    endif
                endif
            next
        next
        return 0
    endif

    if not IsValidMove(col) then
        return 0
    endif

    dropRow = -1
    for r = ROWS - 1 to 0 step -1
        if board[r][col] = 0 then
            dropRow = r
            break
        endif
    next

    board[dropRow][col] = player
    winNow = CheckPattern(player, dropRow, col)
    board[dropRow][col] = 0

    return winNow
endfunc

function CheckPattern (player, r, c)
    ok = 0

    ' Horizontal
    if c <= COLS - CONNECT then
        match = -1
        for k = 0 to CONNECT - 1
            if board[r][c + k] <> player then match = 0
        next
        if match then ok = -1
    endif

    ' Vertical
    if r <= ROWS - CONNECT then
        match = -1
        for k = 0 to CONNECT - 1
            if board[r + k][c] <> player then match = 0
        next
        if match then ok = -1
    endif

    ' Diagonal \
    if r <= ROWS - CONNECT and c <= COLS - CONNECT then
        match = -1
        for k = 0 to CONNECT - 1
            if board[r + k][c + k] <> player then match = 0
        next
        if match then ok = -1
    endif

    ' Diagonal /
    if r >= CONNECT - 1 and c <= COLS - CONNECT then
        match = -1
        for k = 0 to CONNECT - 1
            if board[r - k][c + k] <> player then match = 0
        next
        if match then ok = -1
    endif

    return ok
endfunc

function BoardFull ()
    full = 1
    for c = 0 to COLS - 1
        if board[0][c] = 0 then
            full = 0
            break
        endif
    next
    return full
endfunc

' Returns winning column for 'player', or -1 if none
function FindWinningMove (player)
    for c = 0 to COLS - 1
        if IsValidMove(c) then
            if CheckWinInColumn(player, c) then
                return c
            endif
        endif
    next
    return -1
endfunc

' Evaluates the board from the perspective of 'player'
function EvaluateBoard(player)
    opp = 3 - player  ' opponent: 1<->2
    score = 0

    me2 = 0 ; me3 = 0
    opp2 = 0 ; opp3 = 0

    ' --- Horizontal  ---
    for r = 0 to ROWS - 1
        for c = 0 to COLS - CONNECT
            me = 0 ; opponent = 0
            for k = 0 to CONNECT - 1
                cell = board[r][c + k]
                if cell = player then me = me + 1
                elseif cell = opp then opponent = opponent + 1
            next
            if opponent = 0 then
                if me = 2 then me2 = me2 + 1
                if me = 3 then me3 = me3 + 1
            endif
            if me = 0 then
                if opponent = 2 then opp2 = opp2 + 1
                if opponent = 3 then opp3 = opp3 + 1
            endif
        next
    next

    ' --- Vertical ---
    for c = 0 to COLS - 1
        for r = 0 to ROWS - CONNECT
            me = 0 ; opponent = 0
            for k = 0 to CONNECT - 1
                cell = board[r + k][c]
                if cell = player then me = me + 1
                elseif cell = opp then opponent = opponent + 1
            next
            if opponent = 0 then
                if me = 2 then me2 = me2 + 1
                if me = 3 then me3 = me3 + 1
            endif
            if me = 0 then
                if opponent = 2 then opp2 = opp2 + 1
                if opponent = 3 then opp3 = opp3 + 1
            endif
        next
    next

    ' --- Diagonal \ ---
    for r = 0 to ROWS - CONNECT
        for c = 0 to COLS - CONNECT
            me = 0 ; opponent = 0
            for k = 0 to CONNECT - 1
                cell = board[r + k][c + k]
                if cell = player then me = me + 1
                elseif cell = opp then opponent = opponent + 1
            next
            if opponent = 0 then
                if me = 2 then me2 = me2 + 1
                if me = 3 then me3 = me3 + 1
            endif
            if me = 0 then
                if opponent = 2 then opp2 = opp2 + 1
                if opponent = 3 then opp3 = opp3 + 1
            endif
        next
    next

    ' --- Diagonal / ---
    for r = CONNECT - 1 to ROWS - 1
        for c = 0 to COLS - CONNECT
            me = 0 ; opponent = 0
            for k = 0 to CONNECT - 1
                cell = board[r - k][c + k]
                if cell = player then me = me + 1
                elseif cell = opp then opponent = opponent + 1
            next
            if opponent = 0 then
                if me = 2 then me2 = me2 + 1
                if me = 3 then me3 = me3 + 1
            endif
            if me = 0 then
                if opponent = 2 then opp2 = opp2 + 1
                if opponent = 3 then opp3 = opp3 + 1
            endif
        next
    next

    ' Weighted score: prioritize 3-in-a-row heavily
    score = (me3 * 100) + (me2 * 10) - (opp3 * 100) - (opp2 * 10)
    return score
endfunc

' Improved AI turn
function AITurn()
    col = -1
    action = ""

    ' 1. Can computer win right now?
    col = FindWinningMove(2)
    if col >= 0 then
        action = " (wins!)"
        asm
            jmp place_move:
        endasm
    endif

    ' 2. Must block human's immediate win?
    col = FindWinningMove(1)
    if col >= 0 then
        action = " (blocks you!)"
        asm
            jmp place_move:
        endasm
    endif

    ' 3. Take center column (3) if available — strongest opening
    if IsValidMove(3) then
        col = 3
        action = " (takes center)"
        asm
            jmp place_move:
        endasm
    endif

    ' 4. Evaluate all valid moves and pick best one
    bestScore = -999999
    bestCol = -1

    for c = 0 to COLS - 1
        if IsValidMove(c) then
            r = GetDropRow(c)
            board[r][c] = 2  ' simulate AI move

            score = EvaluateBoard(2)

            board[r][c] = 0  ' undo

            if score > bestScore then
                bestScore = score
                bestCol = c
            endif
        endif
    next

    if bestCol >= 0 then
        col = bestCol
        action = " (strategic)"
    else
        'random (should never happen)
        do
            col = int(rnd() * COLS)
        until IsValidMove(col)
        action = " (fallback)"
    endif
   
    asm
        place_move:
    endasm
    PlaceChip(2, col)
    pln " Computer in column "+ (col + 1) + action
    wait 1000
endfunc

Print this item

  DeepCoin in micro(A)
Posted by: aurel - 01-06-2026, 04:28 PM - Forum: Programming - Replies (16)

some modification for micro(A) IF {var}, {<>=!} ,{var|value} ,{ & | }
blame on me i never add expression under IF statement just variables  [Image: huh.png]

Code:
'Deep Coin by DeepAi and Aurel 6.1.2026
mode 1 : wcolor 0,0,0: fcolor 250,250,255 : swap
' Load images at the start
ptr img1,img2,img3
LoadImg img1, "hero.bmp",  0, 32, 32, 24
LoadImg img2, "ghost.bmp",  0, 32, 32, 24
LoadImg img3, "coin.bmp", 0, 32, 32, 24
var score ,i, spriteXW, spriteXH, spriteXEn, spriteYEn
var spriteWEn, spriteHEn , spriteXWEn , spriteYHEn

' Define arrays for sprite properties
var spriteX[5], spriteY[5], spriteWidth[5], spriteHeight[5]
var spriteSpeedX[5], spriteSpeedY[5]

' Initialize player sprite at index 1
spriteX[1] = 50
spriteY[1] = 100
spriteWidth[1] = 32
spriteHeight[1] = 32

' Initialize enemy sprites at indices 2 to 5
spriteX[2] = 10
spriteY[2] = 20
spriteWidth[2] = 32
spriteHeight[2] = 32
spriteSpeedX[2] = 1
spriteSpeedY[2] = 1

spriteX[3] = 80
spriteY[3] = 50
spriteWidth[3] = 32
spriteHeight[3] = 32
spriteSpeedX[3] = -1
spriteSpeedY[3] = 1

spriteX[4] = 30
spriteY[4] = 70
spriteWidth[4] = 32
spriteHeight[4] = 32
spriteSpeedX[4] = 1
spriteSpeedY[4] = -1

spriteX[5] = 60
spriteY[5] = 30
spriteWidth[5] = 32
spriteHeight[5] = 32
spriteSpeedX[5] = -1
spriteSpeedY[5] = -1

' Initialize coins at indices 6 to 8
var coinX[3], coinY[3], coinWidth[3], coinHeight[3]
coinX[1] = 200
coinY[1] = 100
coinX[2] = 600
coinY[2] = 200
coinX[3] = 400
coinY[3] = 400

coinWidth[1] = 8
coinHeight[1] = 8
coinWidth[2] = 8
coinHeight[2] = 8
coinWidth[3] = 8
coinHeight[3] = 8

' Set screen size (in a graphics environment) SET SCREEN 800, 536

' Initialize score
score = 0

' Main game loop
LABEL mainLoop
    ' Move enemy sprites using WHILE loop
    i = 2
    WHILE i < 6
        spriteX[i] = spriteX[i] + spriteSpeedX[i]
        spriteY[i] = spriteY[i] + spriteSpeedY[i]
       
        ' Bounce on edges (assuming screen size 800x536)
        IF spriteX[i] <= 0 OR spriteX[i] + spriteWidth[i] >= 800 THEN
            spriteSpeedX[i] = -spriteSpeedX[i]
        ENDIF
        IF spriteY[i] <= 0 OR spriteY[i] + spriteHeight[i] >= 536 THEN
            spriteSpeedY[i] = -spriteSpeedY[i]
        ENDIF
        i = i + 1
    WEND

    ' Handle player movement (not implemented here)

    ' Check for collisions with enemies using WHILE loop
    enemyIndex = 2
    WHILE enemyIndex <= 5
        spriteXW   = spriteX[1] + spriteWidth[1]
        spriteYH   = spriteY[1] + spriteHeight[1]
        spriteXEn  = spriteX[enemyIndex]
        spriteYEn  = spriteY[enemyIndex]
        spriteWEn  = spriteWidth[enemyIndex]
        spriteHEn  = spriteHeight[enemyIndex]
        spriteXWEn = spriteXEn + spriteWEn
        spriteYHEn = spriteYEn + spriteHEn
IF spriteXW > spriteXEn & spriteX[1] < spriteXWEn  & spriteYH > spriteYEn & spriteY[1] < spriteYHEn
           ' PRINT "Collision detected between player and enemy "; enemyIndex - 1
           score = score - 10
           PRINT 10,540,"SCORE : " : PRINT 100,540,score
ENDIF
        enemyIndex = enemyIndex + 1
    WEND

    ' Check for collisions with coins using WHILE loop
    c = 1
    WHILE c <= 3
        spriteXW = spriteX[1] + spriteWidth[1]
        spriteYH = spriteY[1] + spriteHeight[1]
        coinXW = coinX[c] + coinWidth[c]
        coinYH = coinY[c] + coinHeight[c]
        IF spriteXW > coinX[c] AND _
           spriteX[1] < coinXW AND _
           spriteYH > coinY[c] AND _
           spriteY[1] < coinYH THEN
            PRINT "Player collected coin "; c
            score = score + 10
            ' Reposition the coin
            coinX[c] = RND * (800 - coinWidth[c])
            coinY[c] = RND * (536 - coinHeight[c])
        END IF
        c = c + 1
    WEND

    PRINT "Score: "; score

    ' Delay for frame rate (depends on environment)
    ' For example: WAIT 0.1 seconds

LOOP

i hope that is now completed .. Angel 

Code:
'Deep Coin by DeepAi and Aurel 6.1.2026
mode 1 : wcolor 0,0,0: fcolor 192,192,192 : swap
' Load images at the start
ptr img1,img2,img3
LoadImg img1, "hero.bmp",  0, 32, 32, 24
LoadImg img2, "ghost.bmp",  0, 32, 32, 24
LoadImg img3, "coin.bmp", 0, 32, 32, 24
var score ,i, c, spriteXW, spriteXH, spriteXEn, spriteYEn
var spriteWEn, spriteHEn , spriteXWEn , spriteYHEn
var true : true = -1
' Define arrays for sprite properties
var spriteX[5], spriteY[5], spriteWidth[5], spriteHeight[5]
var spriteSpeedX[5], spriteSpeedY[5]

' Initialize player sprite at index 1
spriteX[1] = 50
spriteY[1] = 100
spriteWidth[1] = 32
spriteHeight[1] = 32

' Initialize enemy sprites at indices 2 to 5
spriteX[2] = 10
spriteY[2] = 20
spriteWidth[2] = 32
spriteHeight[2] = 32
spriteSpeedX[2] = 1
spriteSpeedY[2] = 1

spriteX[3] = 80
spriteY[3] = 50
spriteWidth[3] = 32
spriteHeight[3] = 32
spriteSpeedX[3] = -1
spriteSpeedY[3] = 1

spriteX[4] = 30
spriteY[4] = 70
spriteWidth[4] = 32
spriteHeight[4] = 32
spriteSpeedX[4] = 1
spriteSpeedY[4] = -1

spriteX[5] = 60
spriteY[5] = 30
spriteWidth[5] = 32
spriteHeight[5] = 32
spriteSpeedX[5] = -1
spriteSpeedY[5] = -1

' Initialize coins at indices 6 to 8
var coinX[3], coinY[3], coinWidth[3], coinHeight[3]
coinX[1] = 200
coinY[1] = 100
coinX[2] = 600
coinY[2] = 200
coinX[3] = 400
coinY[3] = 400

coinWidth[1] = 8
coinHeight[1] = 8
coinWidth[2] = 8
coinHeight[2] = 8
coinWidth[3] = 8
coinHeight[3] = 8

' Set screen size (in a graphics environment) SET SCREEN 800, 536

' Initialize score
score = 0

' Main game loop -------------------------------------------------------
LABEL mainLoop

    'CLS
     RECT true, true , 800, 600
    ' Move enemy sprites using WHILE loop
    i = 2
    WHILE i < 6
        spriteX[i] = spriteX[i] + spriteSpeedX[i]
        spriteY[i] = spriteY[i] + spriteSpeedY[i]
       
        ' Bounce on edges (assuming screen size 800x536)
        spriteXW   = spriteX[1] + spriteWidth[1]
        spriteYH   = spriteY[1] + spriteHeight[1]
        IF spriteX[i] < 1 | spriteXW > 801
            spriteSpeedX[i] = spriteSpeedX[i] - 1
        ENDIF
        IF spriteY[i] < 1 | spriteYH  > 537 THEN
            spriteSpeedY[i] = spriteSpeedY[i] - 1
        ENDIF
        i = i + 1
    WEND

    ' Handle player movement (not implemented here)

    ' Check for collisions with enemies using WHILE loop
    enemyIndex = 2
    WHILE enemyIndex <= 5
        spriteXW   = spriteX[1] + spriteWidth[1]
        spriteYH   = spriteY[1] + spriteHeight[1]
        spriteXEn  = spriteX[enemyIndex]
        spriteYEn  = spriteY[enemyIndex]
        spriteWEn  = spriteWidth[enemyIndex]
        spriteHEn  = spriteHeight[enemyIndex]
        spriteXWEn = spriteXEn + spriteWEn
        spriteYHEn = spriteYEn + spriteHEn
IF spriteXW > spriteXEn & spriteX[1] < spriteXWEn  & spriteYH > spriteYEn & spriteY[1] < spriteYHEn
           ' PRINT "Collision detected between player and enemy "; enemyIndex - 1
           score = score - 10
           'PRINT 10,540,"SCORE : " : PRINT 100,540,score
ENDIF
        enemyIndex = enemyIndex + 1
    WEND

    ' Check for collisions with coins using WHILE loop
    c = 1
    WHILE c < 4
        spriteXW = spriteX[1] + spriteWidth[1]
        spriteYH = spriteY[1] + spriteHeight[1]
        coinXW = coinX[c] + coinWidth[c]
        coinYH = coinY[c] + coinHeight[c]
        IF spriteXW > coinX[c] & spriteX[1] < coinXW &  spriteYH > coinY[c] & spriteY[1] < coinYH
            'PRINT "Player collected coin "; c
            score = score + 10
            ' Reposition the coin
            coinX[c] = RND * (800 - coinWidth[c])
            coinY[c] = RND * (536 - coinHeight[c])
        ENDIF
        c = c + 1
    WEND

    'PRINT "Score: "; score
    fcolor 250,230,100
    PRINT 10,540,"SCORE : " : PRINT 100,540,score

    'Display swap GDI buffers
    SWAP

    ' Delay for frame rate (depends on environment)

Goto mainLoop

source of "game" in code editor

paid attention to this special trick Big Grin

'CLS
    RECT true, true , 800, 600



Attached Files Thumbnail(s)
   
Print this item

  Tic-Tac-Toe
Posted by: 1micha.elok - 01-05-2026, 10:35 AM - Forum: NaaLaa 7 Code - Replies (4)

Here's a classic text-based Tic Tac Toe game — pure nostalgia, no graphics, just clean text and old-school terminal vibes.  And yes — the computer is intentionally easy to beat (as promised) :-)

Code:
' ==========================
' TIC TAC TOE
' Human     (Player 1) = X
' Computer  (Player 2) = O
' ==========================

randomize clock()         ' Initialize random numbers

visible board   =   dim(3, 3)
visible row
visible col
visible player
visible moveCount
visible win

player = 1
moveCount = 0

' Initialize board
for row = 0 to 2
    for col = 0 to 2
        board[row][col] = " "
    next
next


' MAIN GAME loop
do
    DrawBoard()

    if player = 1 then
        ' HUMAN TURN
        pln
        pln "Your turn (X)"
        write "Enter row (0-2): ";
        row = rln(1,TYPE_NUMBER)
        write "Enter column (0-2): ";
        col = rln(1,TYPE_NUMBER)

        if row < 0 or row > 2 or col < 0 or col > 2 then
            pln "Invalid position!"
            wait 3000
        elseif board[row][col] <> " " then
            pln "That spot is taken!"
            wait 3000
        else
            board[row][col] = "X"
            moveCount = moveCount + 1
            CheckWinner()
            if win = 1 then GameOver()
            player = 2
        endif

    else
        ' COMPUTER TURN .... no AI :)
        pln
        write "Computer is thinking..."
        wait 3000

        do
            row = round(rnd() * 2)
            col = round(rnd() * 2)
        until board[row][col] = " "
        pln "["+row+","+col+"]"

        board[row][col] = "O"
        moveCount = moveCount + 1
        CheckWinner()
        if win = 1 then GameOver()
        player = 1
    endif

until moveCount = 9

' DRAW GAME
DrawBoard()
pln
pln "It's a DRAW!"
system("pause")
end


'------------
' FUNCTIONS
'------------
function DrawBoard()
    pln
    pln "   TIC TAC TOE"
    pln
    pln "    0   1   2 "
    pln "  +---+---+---+"
    for row = 0 to 2
        pln row+" | "+ board[row][0]+ " | "+ board[row][1]+ " | "+ board[row][2]+ " | "
        if row < 3 then pln "  +---+---+---+"
    next
endfunc

function CheckWinner()
    win = 0
   
    ' Rows
    for row = 0 to 2
        if board[row][0] <> " " and
           board[row][0] = board[row][1] and
           board[row][1] = board[row][2] then win = 1
    next
   
    ' Columns
    for col = 0 to 2
        if board[0][col] <> " " and
           board[0][col] = board[1][col] and
           board[1][col] = board[2][col] then win = 1
    next
   
    ' Diagonals
    if board[0][0] <> " " and
       board[0][0] = board[1][1] and
       board[1][1] = board[2][2] then win = 1
   
    if board[0][2] <> " " and
       board[0][2] = board[1][1] and
       board[1][1] = board[2][0] then win = 1
endfunc

function GameOver()
    DrawBoard()
    pln

    if player = 1 then
        pln "YOU WIN!"
    else
        pln "COMPUTER WINS!"
    endif
   
    system("pause")
   
    end
endfunc

Print this item

  Compile an n7 file from the windows command line?
Posted by: kevin - 01-03-2026, 04:21 PM - Forum: NaaLaa 7 Questions - Replies (2)

Hi, I seem to recall that this was possible in previous versions? Does anyone here know how this could be done in N7? Thanks.....

Print this item

  Tilemap editor for wolf3d maps
Posted by: Marcus - 01-01-2026, 12:06 PM - Forum: NaaLaa 7 Code - Replies (4)

Here's a first example of how to use the tilemap editor to create maps for the wolf3d library.

Edit: zip updated with step 2, that does doors and pickups



Attached Files
.zip   wolfgame.zip (Size: 1.03 MB / Downloads: 5)
Print this item

  Happy New Year
Posted by: johnno56 - 12-31-2025, 09:58 PM - Forum: Everything else - Replies (5)

Hoping that you all will have a wonderful New Year!!  Enjoy!!

Print this item

  NeoBASIC
Posted by: luwal - 12-27-2025, 02:28 AM - Forum: Programming - Replies (11)

Raylib again. Huh   
https://itch.io/t/5687115/neobasic

Print this item