LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Summer Programming Contest 2017

Root / Site Discussion / [.]

LacksCreated:
Update: I made a huge platformer OSP using text compression. I think I'll use this instead of 3D Pong. Current key: E3S3VXQF
screenshots
EDIT: This has been changed.

Update: I made a huge platformer OSP using text compression. I think I'll use this instead of 3D Pong. Current key: E3S3VXQF
screenshots
You don't need to use FLOOR since MOD sucks and only works with integers. Also if you just use a more simple packing algorithm and store two 8-bit values per character, you can decode it without needing a list of characters (since SB uses a 16 bit encoding), or if you reduce the list down to 31 unique characters, you could fit 3 per character instead of just 2. And if you store the level data in a separate variable, you can just do A$=VAR("0:WHATEVER$") in the compressed program, rather than PRGSETing it.

Also if you just use a more simple packing algorithm and store two 8-bit values per character, you can decode it without needing a list of characters (since SB uses a 16 bit encoding)
I understand everything but this part. Can you show an example on here like:
A$="UNCOMPRESSED TEXT"
'COMPRESSING ALGORITHM
CLIPBOARD A$
'DECOMPRESSING ALGORITHM

A$="UNCOMPRESSED TEXT "'even length
FOR I=0 TO LEN(A$)-1 STEP 2
 INC B$,CHR$(ASC(A$[I]) OR ASC(A$[I+1])<<8)
NEXT
CLIPBOARD B$
FOR I=0 TO LEN(B$)-1
 B=ASC(B$[I])
 INC C$,CHR$(B AND &HFF)
 INC C$,CHR$(B>>8)
NEXT
?C$
Here's a really short version:
'compressor
FOR I=0 TO LEN(A$)-1 STEP 2
 UNSHIFT B$,CHR$(ASC(A$[I]) OR ASC(A$[I+1])<<8)
NEXT
'decompressor
WHILE""<B$B=ASC(POP(B$))C$=C$+CHR$(255AND B)+CHR$(B>>8)WEND
I feel like compressing the code isn't really true OSP anymore though, but it's not technically breaking any of the contest rules, so I guess it's allowed.

I had a lot of fun with this! I loved seeing everyone's entries, too! Here's mine, a simplified Lindenmayer system expander and interpreter with a ruleset generator: 【V3S3XJQS】key graciously donated by 12Me21 and may be revoked without notice
More Good Plants
The interpreter supports stochastic and bracketed (branching) grammars. Gravity affects plant growth. The symbol strings can get very large after a few generations! So please be patient during the drawing process. If the "plant" is swaying, that means it's done drawing. The rule generator uses symbol bigram frequencies I got from some example L-systems to generate results better than random generation, but still often makes less-impressive knots, vines, and snares. About 1 in 8 look nice, though! For this reason, it's best to run it from direct mode. Specifying a seed allows you to generate the same plant by recording the seed value. Try 2, 4731, and 14522. To disable it, see the Editing Guide. I didn't get to add everything I wanted, such as leaf, bud, and flower nodes, or a third dimension (and rendering), or evolutionary selection... but I think it's almost fair for an OSP. You can read more about L-systems here: https://en.wikipedia.org/wiki/L-system
Source Code
ACLS:INPUT"SEED";E:RANDOMIZE.,E:GPAGE.,4GCLS:B$="ABC"F$=B$*3+"["*10+"+-"P$=(B$*3+"+")*2M$=(B$*3+"[-")*2N$="-+"*8+B$+"["E$=B$*2+"["*6+"++--"DIM R$[3,13]FOR I=0TO 2P=10S=0WHILE.<P:N=RND(P)+1P=P-N:R$[I,S]=STR$(100-P*10)A$=(B$*3+"[")[RND(10)]R$[I,S+1]=A$FOR J=RND(6)TO 6U$="]"*K:Q=21Q$=F$+U$*2IF"+"==A$THEN Q=20Q$=P$ELSEIF"-"==A$THEN Q=22Q$=M$ELSEIF"["==A$THEN Q=20Q$=N$ELSEIF"]"==A$THEN Q=16Q$=E$ENDIF:A$=(Q$+U$)[RND(Q+K)]K=K+2*(ABS(INSTR("] [",A$))-1)INC R$[I,S+1],A$+">"*MAX(MIN(K,2),0)NEXT:INC R$[I,S+1],"]"*(K/2)S=S+2K=0WEND:NEXT:DEF GR(C)J=RND(100)N=0WHILE J>VAL(R$[C,N])N=N+2WEND:RETURN R$[C,N+1]END:DEF EV(S$)FOR I=0TO LEN(S$)-1C=ASC(S$[I])IF C>64&&C<91THEN:G$=GR(C-65)S$[I]=G$I=I+LEN(G$)-1:ENDIF:NEXT:RETURN S$END:DEF LD S$DIM H[0]X=0Y=240w=90V=1D=RND(3)+1WHILE.<LEN(S$)&&Y>-20C=ASC(SHIFT(S$))IF C==91THEN PUSH H,V:PUSH H,w:PUSH H,Y:PUSH H,X:ELSEIF C>92THEN X=POP(H)Y=POP(H)w=POP(H)V=POP(H)ELSEIF C<44THEN w=w+20:ELSEIF C==45THEN w=w-20 ELSEIF C==60THEN V=V-2:ELSEIF C==62THEN V=V+2 ELSEIF C>64&&C<91THEN O=RGB(150-V/2,132+V,108-V)FOR I=0TO D:IF Y<-10THEN BREAK:ENDIF:w=w+SGN(X)*ATAN(X,Y+X*(V/&HC350))X=X+COS(RAD(w)):Y=Y-SIN(RAD(w))GPSET X+200,Y,O:NEXT:ENDIF:WEND:END:SPSET.,0,0,#R,#R:SPHOME.,200,240SPOFS.,200,240M$="A"@L:Z=Z+PI()/48?"A Grow"WAIT:CLS:IF BUTTON(2)THEN M$=EV(M$)T$=M$*1LD T$ENDIF:SPROT.,2.5*SIN(Z)GOTO@L
Editing GuideRemoving the Seed Prompt: If you don't care about the randomization seed (the screenshots were generated without it), you can remove INPUT"SEED";E:RANDOMIZE.,E: on the first line. Defining L-systems: It's possible to use your own L-system ruleset, as well. To do so without destroying the generator code, insert a line break on the 26th wrapped line at column position 22, after :WEND:END and define rules by accessing indexes of the 2-dimensional array R. The first dimension of R$ corresponds to letter symbols A-Z: R$[0] is the rule for replacing A, R$[1] for B, and so on. The second dimension is the replacement rules for the corresponding symbol. Every n*2 index starting at n=0 is the probability (as a string) that the following replacement will be made, from 0 to 100. Every n*2+1 index is the replacement. Thus A -> B[+A][-A]BA B ->(.5) BB ->(.5) BBB would be declared with
R$[0,0]="100"R$[0,1]="B[+A][-A]BA"
R$[1,0]="50"R$[1,1]="BB"R$[1,2]="50"R$[1,3]="BBB"
The default size declaration of R$[] is found on the fourth wrapped line, at the second column. The generator uses only symbols A through C for rules. To disable the generator, insert a linebreak on the 12th line in the 24th position (before DEF) and begin a comment at the 13th column of the fourth wrapped line, before "FOR I=0." The symbol table used is shown below.
A-Z : Advance growth by one unit.  Used for expansions.
-   : Decrease angle by 20 degrees
+   : Increase angle by 20 degrees
>   : Shift color towards green by 2 units
<   : Shift color towards brown by 2 units
[   : Push state to the stack
]   : Pop state from the stack
Angle changes are a constant 20 degrees, and unit growth is controlled by the randomized variable D in LD() [L_DRAW()]. For best effects, increase the color with > a few times when beginning a branch.
Lumage

Title: Defender How to Play: Tap enemy ships to destroy them Key: 2J7E33QJ

ill probably be like the last submission lol, cause it keeps changing ideas but idk now.. need something good
No, I will be lol, I just got sick, my grandparents are here so I have no time to program with all the fun events, work, and daily chores. By the end of it all, the last of my energy is spent watching youtube and anime lmao. EDIT:(I also have been having trouble making an entry)
yeah i really need to finish mine today lol. EDIT: lol by today i mean tomorrow at like midnight.

Here's my entry, Frog Guy: https://smilebasicsource.com/page?pid=852 Key: 5D7X33N4 Updated following some optimization advice.

Final update, this project is now compressed far beyond anything should ever be. Huge Platformer OSP- current key: 4RF5Z3N3.
screenshots

There's an even shorter decompressor:
A$="<data>"WHILE""<A$A=ASC(POP(A$))...WEND
FOR I=0TO 1000:A=ASC("<data>"[I])...WEND
(replace 1000 with the compressed text length)

There's an even shorter decompressor:
A$="<data>"WHILE""<A$A=ASC(POP(A$))...WEND
FOR I=0TO 1000:A=ASC("<data>"[I])...WEND
(replace 1000 with the compressed text length)
I think I'm done with this project. But, thanks for all the help!


just so you're paying attention i updated my post
Instead of DATA for the colors, you could do something like
RGB(C MOD 2<<8,(2AND C)<<8,C>>2<<8)
Also, I think you put " CIRC" instead of "CIRCLE" by accident.

just so you're paying attention i updated my post
Instead of DATA for the colors, you could do something like
RGB(C MOD 2<<8,(2AND C)<<8,C>>2<<8)
Also, I think you put " CIRC" instead of "CIRCLE" by accident.
It's called CIRC on purpose because 5 characters to a tool name. Also that algorithm to get the colors is confusing could you explain a bit.

2DVEH3Q4 This was pretty fun to make. Touch the screen to do something. Move the circle pad to do something else.

just so you're paying attention i updated my post
Instead of DATA for the colors, you could do something like
RGB(C MOD 2<<8,(2AND C)<<8,C>>2<<8)
Also, I think you put " CIRC" instead of "CIRCLE" by accident.
It's called CIRC on purpose because 5 characters to a tool name. Also that algorithm to get the colors is confusing could you explain a bit.
CIRC has 4 letters though lol

just so you're paying attention i updated my post
Instead of DATA for the colors, you could do something like
RGB(C MOD 2<<8,(2AND C)<<8,C>>2<<8)
Also, I think you put " CIRC" instead of "CIRCLE" by accident.
It's called CIRC on purpose because 5 characters to a tool name. Also that algorithm to get the colors is confusing could you explain a bit.
CIRC has 4 letters though lol
CIRCLE has 6. Your point?

just so you're paying attention i updated my post
Instead of DATA for the colors, you could do something like
RGB(C MOD 2<<8,(2AND C)<<8,C>>2<<8)
Also, I think you put " CIRC" instead of "CIRCLE" by accident.
It's called CIRC on purpose because 5 characters to a tool name. Also that algorithm to get the colors is confusing could you explain a bit.
CIRC has 4 letters though lol
CIRCLE has 6. Your point?
oh... I guess I can't count lol Why not CIRCL or CRCLE or something, though?

There's an even shorter decompressor:
A$="<data>"WHILE""<A$A=ASC(POP(A$))...WEND
FOR I=0TO 1000:A=ASC("<data>"[I])...WEND
(replace 1000 with the compressed text length)
I think I'm done with this project. But, thanks for all the help!
I'm not going to pretend to understand what I'm looking at... But I do have a few questions: How do you know what symbol of [x] you are using? And given that there is no [x] Character on the Keyboard, how did you type the source code up?

He didn't type it, he used another program to compress it.