Qbasicnews.com
July 02, 2020, 06:35:27 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Drawing AI Challenge  (Read 22396 times)
Z!re
*/-\*
*****
Posts: 4599


« on: June 10, 2005, 07:55:26 PM »

Challenge:
Make an AI that produces some sort of drawings/art..

Sample:
Painter.exe (N for new drawing, Esc to quit)
Thats my old painter AI, should give you an idea of what I mean..

Rules:
* Random images
* AI driven, no user input accepted (see note 2)
* No external files allowed
* No libraries allowed, only native FB/QB commands.
* QB or preferably FB allowed
* Upload the entry to FileAnchor in a zip or rar archive, containing compiled exe and source.
* Drawing must stop by itself, and will only be judged then.
* Painting minimum size is 240x120

Best paintings win..


Ready. Set. Go!




Note: By AI, I mean that the program should work indepetently of user input.

Note 2: This only apply to input that alter the AI directly, or alter the picture in any way. Having a button to make a new painting is allowed.
See painter.exe



EDIT: Rules added!
Logged
Dio
I hold this place together
*****
Posts: 874



« Reply #1 on: June 12, 2005, 12:09:28 AM »

z!re painter is awesome!

all i have lying around is this:


Download CLOUD.EXE
Logged

quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Anonymous
Guest
« Reply #2 on: June 12, 2005, 07:35:02 AM »

omg, that is really cool.

edit: i wanna see your source
Logged
TheDarkJay
I hold this place together
*****
Posts: 913



WWW
« Reply #3 on: June 12, 2005, 12:56:13 PM »

i want to see the source as well, it looks cool (don't worry, i won't cheat. I'm on my honour and i won't press my luck, old saying. Your on your honour. Don't press your luck.).

EDIT

Technically This is AI so this should pass, i haven't run it in fb (though i ran a qb port and it ran very slow near the end)

Code:
SCREENRES 100,100
RANDOMIZE TIMER
DO
x = int((RND * 100)+ 1)
y = int((RND * 100)+ 1)
z = int((RND * 16) + 1)
IF POINT (x,y) <> 0 THEN PSET (x,y), z
LOOP WHILE INKEY$ = ""


This is the QB version i ran

Code:
DIM SHARED screenres(10000)
RANDOMIZE TIMER
SCREEN 13
DO
x = int((RND * 100)+ 1)
y = int((RND * 100)+ 1)
z = int((RND * 16) + 1)
IF screenres(x * y) = 0 THEN
PSET (x, y), z
screenres(x * y) = z
END IF
LOOP WHILE INKEY$ = ""
Logged

url=http://www.sloganizer.net/en/][/url]
Z!re
*/-\*
*****
Posts: 4599


« Reply #4 on: June 12, 2005, 04:52:26 PM »

About the Painter source:
The program is old, very very old. And I'm not sure I still have the source, I'll look around for it.
But basically, it's a particle engine, that plots a pixel when it's blocked and cannot continue towards it's group.
A group is made up of dots with a certain color range, the dots in each group all try to move to the group center.

Quote from: "Dio"
z!re painter is awesome!

all i have lying around is this:


Download CLOUD.EXE

Quote from: "Z!re"
* Upload the entry to FileAnchor in a zip or rar archive, containing compiled exe and source.

If you want to enter that is Cheesy


TheDarkJay, your entry is perfectly valid, except being too small. Tongue
Logged
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #5 on: June 12, 2005, 06:41:23 PM »

:lol: Mine is bigger...

[syntax="FreeBasic"]' Imagination.bas: AI Drawer: by Rattrapmax6(Kevin)
' Drafts shaded lines, and inturn alows you to make out
' a wireframe structure.. e.i. I see a city scape w/ buildings
' and streets after awhile.. ^_^

'Clicking window's X closes while drawing
' N = New pic after Pic is done
' ESC & Window X = Exit after pic is finished
'  Enjoy!!

SCREEN 18, 32

DECLARE SUB rnd_motion
DO: CLS
DIM SHARED MinX = 10, MaxX = 260
DIM SHARED MinY = 10, MaxY = 140
DIM SHARED x, y, area, xv, yv
RANDOMIZE TIMER
cont = 0
MinX = 10: MaxX = 500
MinY = 10: MaxY = 400
area = 191100: x = 10: y = 10
xv = 1: yv = 1
DO
    IF INKEY$ = CHR$(255) + "X" THEN END
   
    rndcol = INT(RND * 255) + 1
    rnd_motion
    lineL = INT(RND * 20) + 1
    FOR i = 1 TO LineL
         cont = cont + 1
        IF y < MinY THEN yv = 1
        IF y > MaxY THEN yv = -1
        IF x < MinX THEN xv = 1
        IF x > MaxX THEN xv = -1
        x = x + xv
        y = y + yv
        PSET (x, y), RGB(0, rndcol, rndcol)
    NEXT
    T! = TIMER    
    DO: LOOP UNTIL (TIMER - T!) >= .005
    LOCATE 28, 1: PRINT INT((cont / area) * 100); "%"
LOOP UNTIL cont >= area
DO
   
    press$ = INKEY$
    IF press$ = CHR$(27) THEN END
    IF press$ = CHR$(255) + "X" THEN END
    IF UCASE$(press$) = "N" THEN EXIT DO
LOOP
LOOP

SUB rnd_motion
    'How many motions:
    M = INT(RND * 3) + 1
    'Up down
    IF M = 1 THEN
        R1 = INT(RND * 2) + 1
        IF R1 = 1 THEN yv = -1
        IF R1 = 2 THEN yv = 1
        'Left right
        R2 = INT(RND * 2) + 1
        IF R2 = 1 THEN xv = -1
        IF R2 = 2 THEN xv = 1
    ELSEIF M = 2 THEN
        'Up down
        IF M = 1 THEN
        R1 = INT(RND * 2) + 1
        IF R1 = 1 THEN yv = -1
        IF R1 = 2 THEN yv = 1
        xv = 0
    ELSEIF M = 3 THEN
        'Left right
        R2 = INT(RND * 2) + 1
        IF R2 = 1 THEN xv = -1
        IF R2 = 2 THEN xv = 1
        yv = 0
    END IF
    END IF
END SUB [/syntax]
Logged

Kevin (x.t.r.GRAPHICS)

Z!re
*/-\*
*****
Posts: 4599


« Reply #6 on: June 12, 2005, 08:24:26 PM »

Nice rat, but it gets boring pretty quick..

And it's always "the same" drawing
Logged
TheDarkJay
I hold this place together
*****
Posts: 913



WWW
« Reply #7 on: June 13, 2005, 12:02:45 PM »

isn't size something most challenges want you to reduce, lol. The smaller the better.
Logged

url=http://www.sloganizer.net/en/][/url]
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #8 on: June 13, 2005, 05:40:32 PM »

Its ment to be Random... heh..  :roll:

Well,. If I can enter twice:

[syntax="FreeBasic"]' Wild Painter: By Rattrapmax6(Kevin)

'Painting:
'Window X (click) = END

'Not Painting:
'Window X (Click) = END
'ESC = END
'N = New Picture

'Enjoy!!

SCREEN 14, 32

RANDOMIZE TIMER

MxX = 300: MxY = 200
MnX = 10: MnY = 10
Area = 1000

DO: CLS
cont = 0
X = 10
Y = 10
DO
    press$ = INKEY$
    'Select tool
    T = INT(RND * 3) + 1
    IF T = 1 THEN 'Line
        M = INT(RND * 2) + 1
        IF M = 1 THEN YV = 1
        IF M = 2 THEN YV = -1
        M = INT(RND * 2) + 1
        IF M = 1 THEN XV = 1
        IF M = 2 THEN XV = -1
        SX = INT(RND * (300 - 10 + 1) + 10)
        SY = INT(RND * (300 - 10 + 1) + 10)
        LoopL = INT(RND * 30) + 1
        FOR i = 1 TO LoopL
            cont = cont + 1
            RD = INT(RND * 255) + 1
            GR = INT(RND * 255) + 1
            BL = INT(RND * 255) + 1
            IF X > MxX THEN XV = -1
            IF X < MnX THEN XV = 1
            IF Y > MxY THEN YV = -1
            IF Y < MnY THEN YV = 1
            X = X + XV
            Y = Y + YV
            LINE (SX, SY)-(X, Y), RGB(RD,GR,BL)
            SLEEP 100
        NEXT
       
    ELSEIF T = 2 THEN 'Circle
        NC = INT(RND * 30) + 1
        FL = INT(RND * 2) + 1
        FOR i = 1 TO NC
            cont = cont + 1
            RD = INT(RND * 255) + 1
            GR = INT(RND * 255) + 1
            BL = INT(RND * 255) + 1
            SX = INT(RND * (300 - 10 + 1) + 10)
            SY = INT(RND * (300 - 10 + 1) + 10)
            R = INT(RND * 20) + 1
            CIRCLE (SX, SY), R, RGB(RD,GR,BL)
            IF FL = 2 THEN PAINT (SX, SY), RGB(RD,GR,BL)
            SLEEP 100
        NEXT
       
    ELSEIF T = 3 THEN 'Pixel
        NP = INT(RND * 30) + 1
        FOR i = 1 TO NC
            cont = cont + 1
            RD = INT(RND * 255) + 1
            GR = INT(RND * 255) + 1
            BL = INT(RND * 255) + 1
            SX = INT(RND * (300 - 10 + 1) + 10)
            SY = INT(RND * (300 - 10 + 1) + 10)
            PSET (SX, SY), RGB(RD,GR,BL)
            SLEEP 100
        NEXT
    END IF
   
    IF X > MxX THEN XV = -1
    IF X < MnX THEN XV = 1
    IF Y > MxY THEN YV = -1
    IF Y < MnY THEN YV = 1
    X = X + XV
    Y = Y + YV
    IF press$ = CHR$(255) + "X" THEN END
    LOCATE 1, 1: PRINT INT((cont / area) * 100); "%"
LOOP UNTIL Cont >= Area

DO
    press$ = INKEY$
    IF press$ = CHR$(27) THEN END
    IF press$ = CHR$(255) + "X" THEN END
    IF UCASE$(press$) = "N" THEN EXIT DO
LOOP
LOOP


[/syntax]
Logged

Kevin (x.t.r.GRAPHICS)

TheDarkJay
I hold this place together
*****
Posts: 913



WWW
« Reply #9 on: June 13, 2005, 05:50:15 PM »

Code:
SCREENRES 100,100
RANDOMIZE TIMER
DO
x = int((RND * 100)+ 1)
y = int((RND * 100)+ 1)
z = int((RND * 16) + 1)
IF POINT (x,y) = 0 THEN PSET (x,y), z
LOOP WHILE INKEY$ = ""


Just spotted a problem in my code, i did <> instead of = (i was trying a black and white one originally and stopped half way and changed to colour. This was a reminent of then
Logged

url=http://www.sloganizer.net/en/][/url]
Z!re
*/-\*
*****
Posts: 4599


« Reply #10 on: July 20, 2005, 11:55:09 AM »

Bump...
Logged
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #11 on: July 29, 2005, 11:17:59 PM »

Sorry to be a party pooper, but none of these so far can be said to be AI.

I would say more of a random algorithm generated image.

(apart from maybe Z!re's original)
Logged
JasonSG
New Member

Posts: 20


« Reply #12 on: August 05, 2005, 11:17:56 PM »

I'm working on creating something like painter.exe (based on your discription of it), but I cant seem to get it to run nearly as fast nor to create anyting nearly as interesting.  What I have it doing is having a given number of groups (all things I say are a given number are defined by const in the code) each consisting of a given set of different colors creating a picture of a given size in a given screen (currently 13).  What I have it do is generate a different random spot for each pixel, a random color within the range, and a random rate of change for the color.  I have it set to execute a set of code over and over until the whole picture is made.  All pixels try to move toward the center of their group (the average of all the x's and the average of all the y's of the pixels in that group).  When they cannot go to the next pixel they want to, or if they are in the center of their group, they plot and 'die' otherwise, they move.  When a pixel 'dies', a sub called RegenPxls gives them a new random coordanate and color that nothing occupies and plots it their.  However, it takes an imensely long time to regernerate them even once.  Here is my code:
Code:
DECLARE SUB PlotPxl (Pxl!)
DECLARE SUB RegenPxl ()
DECLARE FUNCTION Center! (Group!)
DECLARE SUB CreateGroups ()
OPTION BASE 1
'Declare constants for easy edit-ability.  The names are as follows:
'SNum        - SCREEN number
'SWidth      - SCREEN Width
'SHeight     - SCREEN Height
'SLColor     - The lower limit of the colors
'SUColor     - The upper limit of the colors
'Groups      - The number of ranges of pixels you want
'SBorder     - The width of the pixel border
'LPalette    - The lower limit of the palettes (set to 0 if not using palettes)
'UPalette    - The upper limit of the palettes (set to 0 if not using palettes)
'NotUsed     - The middle number of the group of colors not used
'CustGroups  - -1 only if you will define your own color groups
'SpaceGroups - The number of blank pixels between each group
'Pxls        - The number of pixels you want to have per group.
CONST SNum = 13
CONST SWidth = 320, SHeight = 200
CONST SLColor = 0, SUColor = 255
CONST Groups = 8
CONST SBorder = 10
CONST LPalette = 0, UPalette = 0
CONST NotUsed = 0
CONST CustGroups = -1, SpaceGroups = 0
CONST Pxls = 10
COMMON SHARED Picture()
COMMON SHARED ColorGroups()
CG = Groups
CS = INT((SUColor - SLColor + 1) / Groups - SpaceGroups)
DIM SHARED ColorGroups(CG, CS)
DIM SHARED PxlEngine(Pxls * Groups, 6)
SW = SWidth
SH = SHeight
DIM SHARED Picture(SW, SH)
SCREEN SNum
KEY 15, CHR$(0) + CHR$(49)
KEY 16, CHR$(0) + CHR$(1)
ON KEY(15) GOSUB beginner
ON KEY(16) GOSUB leaver
KEY(15) ON
KEY(16) ON
ERASE PxlEngine, Picture, ColorGroups
REDIM SHARED PxlEngine(Pxls * Groups, 6)
REDIM SHARED Picture(SW, SH)
REDIM SHARED ColorGroups(CG, CS)
IF CustGroups THEN
'================Edit this if you are making custom groups==============
        FOR y = 1 TO 8
                FOR x = 1 TO 32
                        READ colors
                        ColorGroups(y, x) = colors
                NEXT x
        NEXT y
        DATA 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
        DATA 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
        DATA 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95
        DATA 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127
        DATA 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159
        DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
        DATA 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
        DATA 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
'========================================================================
ELSE
        CALL CreateGroups
END IF
begin:
RESET
KEY(15) ON
KEY(16) ON
RANDOMIZE TIMER
ERASE PxlEngine, Picture
REDIM SHARED PxlEngine(Pxls * Groups, 6)
REDIM SHARED Picture(SW, SH)
FOR i = 1 TO Pxls * Groups
        DO
                works = -1
                PxlEngine(i, 1) = INT((SWidth - SBorder - SBorder + 1) * RND + SBorder)'x
                PxlEngine(i, 2) = INT((SHeight - SBorder - SBorder + 1) * RND + SBorder)'y
                FOR a = 1 TO i - 1
                        IF PxlEngine(a, 1) = PxlEngine(i, 1) AND PxlEngine(a, 2) = PxlEngine(i, 2) THEN
                                works = 0
                                EXIT FOR
                        END IF
                NEXT a
        LOOP UNTIL works
        PxlEngine(i, 3) = INT((i - 1) / Pxls + 1) 'group
        PxlEngine(i, 4) = INT(INT((SUColor - SLColor + 1) / Groups - SpaceGroups) * RND + 1) 'color
        PxlEngine(i, 5) = INT((3 - 1 + 1) * RND + 1) 'rate of change for color
        PxlEngine(i, 6) = -1 'alive (-1) or dead (0)
NEXT i
CLS
FOR i = 1 TO Pxls * Groups
        LINE (PxlEngine(i, 1), PxlEngine(i, 2))-(PxlEngine(i, 1), PxlEngine(i, 2)), ColorGroups(PxlEngine(i, 3), PxlEngine(i, 4))
        'Picture(PxlEngine(i, 1) + 1, PxlEngine(i, 2) + 1) = ColorGroups(PxlEngine(i, 3), PxlEngine(i, 4))
NEXT i
DO
        done = -1
        FOR x = SBorder TO SWidth - SBorder
                FOR y = SBorder TO SHeight - SBorder
                        IF Picture(x, y) = 0 THEN
                                done = 0
                                EXIT FOR
                        END IF
                NEXT y
                IF working = 0 THEN EXIT FOR
        NEXT x
        FOR i = 1 TO Pxls * Groups
                CALL PlotPxl(i)
        NEXT i
        CALL RegenPxl
LOOP UNTIL done
ik$ = ""
WHILE ik$ <> "n" AND ik$ <> CHR$(0) + CHR$(1)
        ik$ = LCASE$(INKEY$)
WEND
END
beginner: RETURN begin
leaver: END

FUNCTION Center (Group)
        total = 0
        SumX = 0
        SumY = 0
        FOR x = SBorder TO SWidth - SBorder
                FOR y = SBorder TO SHeight - SBorder
                        FOR c = 1 TO INT((SUColor - SLColor + 1) / Groups - SpaceGroups)
                                IF Picture(x, y) = ColorGroups(Group, c) THEN
                                        SumX = SumX + x
                                        SumY = SumY + y
                                        total = total + 1
                                END IF
                        NEXT c
                NEXT y
                IF working = 0 THEN EXIT FOR
        NEXT x
        IF total = 0 THEN
                FOR i = 1 TO Pxls * Groups
                        IF PxlEngine(i, 3) = Group THEN
                                SumX = SumX + PxlEngine(i, 1)
                                SumY = SumY + PxlEngine(i, 2)
                                total = total + 1
                        END IF
                NEXT i
        END IF
        Center = INT(SumX / (total - (total = 0))) + INT(SumY / (total - (total = 0))) / 1000
END FUNCTION

SUB CreateGroups
        FOR i = 1 TO Groups
                counter = 1
                FOR c = (i - 1) * INT((SUColor - SLColor + 1) / Groups) TO i * INT((SUColor - SLColor + 1) / Groups - SpaceGroups)
                        ColorGroups(i, counter) = c
                        counter = counter + 1
                NEXT c
        NEXT i
END SUB

SUB PlotPxl (Pxl)
        GCenter = Center(PxlEngine(Pxl, 3))
        GCenterX = INT(GCenter)
        GCenterY = 1000 * (GCenter - INT(GCenter))
        IF GCenterX = PxlEngine(Pxl, 1) AND GCenterY = PxlEngine(Pxl, 2) THEN
                Picture(PxlEngine(Pxl, 1), PxlEngine(Pxl, 2)) = ColorGroups(PxlEngine(Pxl, 3), PxlEngine(Pxl, 4))
                PxlEngine(Pxl, 6) = 0
                EXIT SUB
        END IF
        working = -1
        TryX = PxlEngine(Pxl, 1) - (PxlEngine(Pxl, 1) - GCenterX) / ABS(PxlEngine(Pxl, 1) - GCenterX - (PxlEngine(Pxl, 1) - GCenterX) = 0)
        TryY = PxlEngine(Pxl, 2) - (PxlEngine(Pxl, 2) - GCenterY) / ABS(PxlEngine(Pxl, 2) - GCenterY - (PxlEngine(Pxl, 2) - GCenterY) = 0)
        works = -1
        FOR i = 1 TO Pxls * Groups
                IF PxlEngine(i, 1) = TryX AND PxlEngine(i, 2) = TryY THEN
                        works = 0
                        EXIT FOR
                END IF
        NEXT i
        IF NOT works THEN
                Picture(PxlEngine(Pxl, 1), PxlEngine(Pxl, 2)) = ColorGroups(PxlEngine(Pxl, 3), PxlEngine(Pxl, 4))
                PxlEngine(Pxl, 6) = 0
                EXIT SUB
        END IF
        LINE (PxlEngine(Pxl, 1), PxlEngine(Pxl, 2))-(PxlEngine(Pxl, 1), PxlEngine(Pxl, 2)), 0
        PxlEngine(Pxl, 1) = TryX
        PxlEngine(Pxl, 2) = TryY
        PxlEngine(Pxl, 4) = PxlEngine(Pxl, 4) + PxlEngine(Pxl, 5)
        IF PxlEngine(Pxl, 4) < 1 THEN
                PxlEngine(Pxl, 4) = 1
                PxlEngine(Pxl, 5) = INT((3 - 1 + 1) * RND + 1)
        ELSEIF PxlEngine(Pxl, 4) > INT((SUColor - SLColor + 1) / Groups - SpaceGroups) THEN
                PxlEngine(Pxl, 4) = INT((SUColor - SLColor + 1) / Groups - SpaceGroups)
                PxlEngine(Pxl, 5) = -INT((3 - 1 + 1) * RND + 1)
        END IF
        LINE (PxlEngine(Pxl, 1), PxlEngine(Pxl, 2))-(PxlEngine(Pxl, 1), PxlEngine(Pxl, 2)), ColorGroups(PxlEngine(Pxl, 3), PxlEngine(Pxl, 4))
END SUB

SUB RegenPxl
        FOR i = 1 TO Pxls * Groups
                IF NOT PxlEngine(i, 6) THEN
                        DO
                                works = -1
                                PxlEngine(i, 1) = INT((SWidth - SBorder - SBorder + 1) * RND + SBorder)
                                PxlEngine(i, 2) = INT((SHeight - SBorder - SBorder + 1) * RND + SBorder)
                                FOR a = 1 TO Pxls * Groups
                                        IF (PxlEngine(a, 1) = PxlEngine(i, 1) AND PxlEngine(a, 2) = PxlEngine(i, 2) AND a <> i) OR Picture(PxlEngine(i, 1), PxlEngine(i, 2)) <> 0 THEN
                                                works = 0
                                                EXIT FOR
                                        END IF
                                NEXT a
                        LOOP UNTIL works
                        PxlEngine(i, 4) = INT(INT((SUColor - SLColor + 1) / Groups - SpaceGroups) * RND + 1) 'color
                        PxlEngine(i, 5) = INT((3 - 1 + 1) * RND + 1) 'rate of change for color
                        PxlEngine(i, 6) = -1 'alive (-1) or dead (0)
                        LINE (PxlEngine(i, 1), PxlEngine(i, 2))-(PxlEngine(i, 1), PxlEngine(i, 2)), ColorGroups(PxlEngine(i, 3), PxlEngine(i, 4))
                END IF
        NEXT i
END SUB


Sorry for the (almost) complete lack of comments (a bad habbit of mine).  Any advice/suggestions on my code, in addition to any additonal discription of the source code of painer.exe would be greatly appreciated.

Edit: I fixed a few errors in my code, so now it finishes in a resonable amount of time, but it still is nothing like painer.exe.  I am not sure how to make it less like random movement and more like an AI (I'm thinking maybe get rid of the part of code where the pixels 'die' or something like that, or make where they are regenerated less random).
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #13 on: August 07, 2005, 06:51:44 PM »

I dont have time to look at your source, sorry..


Painter use a pack algorithm, where each dot tries to go for one of it's own approximate kind, their kind/groups are based on their colour.

If a dot is trapped on all sides it jumps out to the border of the picture, where it goes around until it finds a gap.

If a dot is blocked in it's path, either by another dot, or by the drawing itself, it leaves behind a single pixel of it's own color there, then tries to find an alternative route.


It all sound far more advanced than it really was.. Only about 150 lines of code or so.. too bad I lost it, would've been fun to mess with..
Logged
Pyrodap
Senior Member
**
Posts: 166



« Reply #14 on: August 08, 2005, 02:13:16 AM »

Code:
Screen 12,8,2,0
Size=20 'Size of the "flames"
S=1
ScreenSet S,1-S
For X=0 to 639
Pset (X,479),Int(Rnd*200)+1
Next
    Do
ScreenSet S,1-S
For Y=479 to 0 step -1
    For X=1 to 638
    If Int(Rnd*Size)+1<>1 Then Pset(X,Y-1),Point(X+Int(Rnd*3)-1,Y)
    Next
Next
ScreenCopy S,1-S
S=1-S
    Loop while inkey$=""
Sleep


Slow but... interesting.
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!