|
Pages: [1] 2 3
|
 |
|
Author
|
Topic: Drawing AI Challenge (Read 9714 times)
|
Z!re
*/-\*
    
Posts: 4599
|
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
|
|
|
|
|
|
Anonymous
Guest
|
omg, that is really cool.
edit: i wanna see your source
|
|
|
|
|
Logged
|
|
|
|
TheDarkJay
I hold this place together
    
Posts: 913

|
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) 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 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
|
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. * Upload the entry to FileAnchor in a zip or rar archive, containing compiled exe and source. If you want to enter that is TheDarkJay, your entry is perfectly valid, except being too small. 
|
|
|
|
|
Logged
|
|
|
|
Rattrapmax6
__/--\__
    
Posts: 2577

|
: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) 
|
|
|
|
|
|
|
Rattrapmax6
__/--\__
    
Posts: 2577

|
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) 
|
|
|
|
|
|
|
|
|
JasonSG
New Member
Posts: 20
|
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: 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
|
|
|
|
|
|
Pyrodap
Senior Member
 
Posts: 166

|
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
|
|
|
|
|