当前位置: 首页>>趣味编程>>正文


Pixel art,episode 2:显示Super Mario Bros的Map1-1

梦回大唐 趣味编程 , , 去评论

问题描述

最后的挑战(Pixel-art, episode 1: display Super Mario)只是一个训练…(而且你以惊人的方式完成了,谢谢!)

这一次,你必须多一点工作。你必须在NES上显示超级马里奥兄弟的所有第一个世界Map,没有敌人,没有马里奥。

您的程序或功能必须显示以下图像的所有像素,或者产生与其类似的图像文件(BMP,PNG或GIF)。

您的程序不得以任何方式访问互联网。

如果需要,可以放大输出,如果需要,像素可以是ASCII或HTML元素,只要它们具有正确的颜色。

这是您必须遵循的模式:


Sky blue: #5C94FC
Black: #000000
Pink: #FCBCB0 (for the blocks and the castle)
Brown: #C84C0C (for the blocks and the castle)
Orange: #FC9838 (for the "?" block)
Light green: #80D010 (for bushes, mountains, flagpole, warp)
Dark green: #00A800 (for bushes, mountains, flagpole, warp)
White: #FCFCFC (clouds)
Light blue: #3CBCFC (clouds)

最短的答案赢了。

编辑:将有两个记分卡,其中分数以字节计数,一个以字符计算。

祝你好运!

P.S:以下是一些可以帮助您优化程序的注释:

  • 云,灌木丛和山脉有重复的模式(每48列)

  • 飞行块只存在于第4行和第8行

  • Map的每个瓷砖或精灵最多使用4种颜色(包括蓝色或透明,取决于您的看法)

  • 灌木丛只是“云顶”与不同的调色板

  • 单一,双重和三重灌木/云可以使用相同的迷你集16x16px片段轻松形成。单山三山也是如此

最佳解决方案

x86机器代码,1729 1619 1468 1382字节

它是如何工作的:瓷砖是由RLE压缩,2bit图像和程序代码的组合产生的。一旦瓦片在内存中生成,程序就会创建一个瓦片索引矩阵。这首先加载了重复的背景。之后,管道,浮块,金字塔和旗杆被程序绘制。管道,丘陵,灌木丛和金字塔可以延伸到地面以下,但在下一步写下岩石瓦片时,它们将被覆盖。最后,将城堡瓦片值简单地复制到正确的位置。要生成图像文件,BMP头和调色板作为数据存储在文件中,并首先写入。然后,程序运行矩阵,从每个位置的相应瓦片中写入适当的行。

用法:运行mario.com,它将生成”m.bmp”,一个标准的BMP图像文件。该文件被创建为一个隐藏文件,因为最终减少了字节。

Download a ZIP file containing the source code and binary, plus output.

code-golf,kolmogorov-complexity,graphical-output

汇编代码生成可执行文件:

org 100h
code_start:

;xor    cx,cx
mov    cx,12+14+256*3
mov    dx,filename
mov    ah,0x3c
int    21h
mov    bx,ax
push   ax


;mov    dx,BITMAPFILEHEADER
inc    dx
inc    dx
mov    ah,0x40
int    21h


mov di,tiles
xor ax,ax
mov ch,48
rep stosw

cwd             ; load the cloud sprite
mov si,cloud
call    DrawSprite
call    DrawHill

mov dx,14*256+12*16
PipeTileLoop:                ;Pipe
mov si,pipe0
call    DrawSprite
sub dh,2
jns PipeTileLoop

mov dx,32+12*16
call    DrawSprite
mov dh,13
;mov     si,pipe2
call    DrawSprite

cwd
xor ax,ax                ; move to the tile array
mov cl,6
MoveTileLoop:
call    MoveTile
loop    MoveTileLoop
mov word [BITMAPFILEHEADER+5+2],0x607     ; bushes
sub dl,3*16
mov cl,13
jnc MoveTileLoop

mov dx,0x1004
mov si,ball
call    DrawSprite
mov dl,0
call    MoveTile

xor bx,bx       ; pole
pole:
mov word[bx+tiles+22*256+7],0x707
add bl,16;
jnc pole

mov word [BITMAPFILEHEADER+5+2],0x805      ; qbrick
mov si,qbrick
call    DrawSprite
call    MoveTile

mov byte[BITMAPFILEHEADER+5+3],4

mov al,1            ; bricks & castle
call    Clear
mov al,23
call    MoveTile        ; black door
mov dx,0x800+64
BrickLoop:
xor dh,8
mov si,bricks
call    DrawSprite
sub dl,dh
jg  BrickLoop

cwd
call    MoveTile         ; left window
call    MoveTile         ; castle brick
mov al,3
mov di,image+15*256+16
mov cl,16
rep stosb
mov al,26
mov dl,16
call    MoveTile         ; reg brick

;mov     dl,32
;mov     si,door
call    DrawSprite
;mov     dl,32
call    MoveTile        ; door top
mov dx,48 +8*256
;mov     si,cren
call    DrawSprite
push    si

mov dh,0
call    MoveTile        ; crenulation 1
mov si,image+48+256  +4
mov di,image+48+256*9+4
mov bl,7
CrenLoop:
mov cl,7
rep movsb
mov dl,256-7
add si,dx
add di,dx
dec bx
jnz CrenLoop
mov dl,3*16
call    MoveTile        ; crenulation 2

pop si
mov cl,3
jmp skip
LastLoop:
;call    MoveTile        ; right window
                 ; block
                 ; rocks
call    DrawSprite
skip:
call    MoveTile
loop    LastLoop



xor ax,ax              ; Begin drawing world using the tiles
call    Clear
mov bl,48*4
BackgroundLoop:
lea di,[bx+image+2*256]
SmallHill:
mov al,10
mov cl,5
HillRow0:
stosb
inc ax
loop    HillRow0
mov dword [di+256-4],10+11*256+256*256*14
mov byte [di+512-3],15
sub di,256-10
cmp di,image +256
ja  SmallHill

mov si,fluff         ; draw clouds, bushes
FluffDrawLoop:
lodsw
add ax,bx
add ax,image
xchg    ax,di
lodsb
aam
mov cl,ah
;call    DrawFluff;

mov ah,1
FluffLayer2:
stosb
inc ax
push    cx
rep stosb
inc ax
stosb
pop cx
add di,256-2
sub di,cx
inc ax
dec ah
jns FluffLayer2

cmp si,pa
jl  FluffDrawLoop

sub bl,48
jnc BackgroundLoop

;mov     si,pa
mov cl,6
PipePlace:
lodsw
xchg    bx,ax
mov di,image
mov word [bx+di],18+19*256
PipeLoop:
dec bh
mov word[bx+di],16+17*256
jnz PipeLoop
loop    PipePlace

;mov     si,dba          ; draw the various floating blocks
mov cl,4
DrawBlockLoop:
lodsw
xchg    ax,bx
mov ah,bl

cwd
lodsb
BlockLoop:
mov bl,al
mov byte [bx+di],ah
lodsb
cmp al,dh
mov dh,al
ja  BlockLoop

dec si
loop    DrawBlockLoop

mov bx,198+256*12
FlagPole:             ; Draw flag pole
mov byte [bx+di],22
dec bh
jg  FlagPole
inc si
;mov     si,pyr            ; pyramid blocks
mov cl,8
PyrMainLoop:
lodsw
shr ah,1
cwd
inc dx
jnc NoNeg
neg dx
NoNeg:
mov bx,ax
PyrDrawLoop:
mov byte [bx+di],32
dec bh
jnz PyrDrawLoop
add ax,dx
dec ah
jnz NoNeg
loop    PyrMainLoop


;mov     si,ground        ; ground blocks
;mov     di,image
mov bl,4
push    di
GroundLoop:
lodsb
xchg    ax,cx
mov al,33
rep stosb
lodsb
add di,ax
dec bx
jnz GroundLoop
push    si
inc ch
mov si,di
sub si,cx
rep movsb

pop si
pop di
;push    di
;mov     si,copy         ; Draw Castle, flag ball
mov  dl,6
CopyLoop:
lodsw
mov cx,ax
shr cx,12
and ah,15
xchg    bx,ax
CopyRun:
lodsb
mov [bx+di],al
inc bx
loop    CopyRun
dec dx
jnz CopyLoop;

xor ax,ax
xor bx,bx ; image y        ; write the image to file
pop dx
WriteTileStep:
WriteRowStep:
mov bl,0 ; image x
WriteStep:
pusha
mov ah,[bx+di]
mov bx,dx
add ax,tiles
xchg    ax,dx
mov cl,16
mov ah,0x40
int 21h
popa
inc bx
cmp bl,212
jb  WriteStep
add al,16
jnz WriteRowStep
inc bh
cmp bh,14
jl  WriteTileStep
;pop     bx
;mov     ah,0x3e
;int     21h

;ret


DrawSprite: ; dx=x,y, si=data
pusha
mov bp,dx
;cwd
mov di,temp
push    di
lodsw              ; w, h*2+flag
mov dl,al
shr ah,1
pushf
mul ah
xchg    bx,ax
popf
jc  BitMapped
RunLoop:
lodsb
mov cl,al
shr cx,2
sub bx,cx
rep stosb
jnz RunLoop
jmp MoveData
BitMapped:
BitMappedLoop:
lodsb
mov cl,4
BitMappedQuad:
stosb
shr ax,2
loop    BitMappedQuad
sub bx,4
jg  BitMappedLoop
MoveData:
mov bx,sp
mov [bx+4],si
pop si
mov bx,di
lea di,[bp+image]
mov dh,-1
MoveLoop:
mov cl,dl
rep movsb
sub di,dx
cmp si,bx
jl  MoveLoop
popa
ret

MoveTile: ; dx =x,y, bx=y,ax=t-1
inc ax
pusha
mov si,dx

xchg    al,ah
xchg    di,ax
mov ax,16
TileLoop:
mov cl,16
TileTrans:
mov bx,[si+image]
inc si
and bx,3
mov bl,[bx+BITMAPFILEHEADER+5]
mov [di+tiles],bl
inc di
loop    TileTrans
add si,256-16
dec ax
jnz TileLoop
popa
add dl,16
ret

Clear: ; al = value
mov di,image
mov ch,48
rep stosb
ret;

DrawHill:
pusha
xor bx,bx
mov al,3
HillLoop:
lea di,[bx+image+6*16]
inc byte [di]
inc di
mov cl,16*5-2
sub cl,bl
sub cl,bl
rep stosb
inc byte [di]
inc bx
inc bh
cmp bl,16
jl  HillLoop

mov si,spot
push    si
mov dx,32-7+256*8 + 6*16
call    DrawSprite
mov dl,32+17    + 6*16
pop si
call    DrawSprite
mov dx,5*16      + 6*16
call    DrawSprite
popa
ret

filename: db 'm','.'
BITMAPFILEHEADER: db 66,77,'P',0,12,0,1,2,3,0,26,3,0,0
BITMAPCOREHEADER: db 12,0,0,0,64,13,224,0,1,0,8,0
colors: db 252,148,92,0,0,0,252,252,252,252,188,60,176,188,252,12,76,200,0,168,0,16,208,128,56,152,252

;pal: db 0,1,2,3
cloud: db 88,32,224,5,114,5,228,5,122,5,224,5,122,5,228,9,106,5,6,5,240,102,5,4,5,240,5,86,5,10,5,252,5,78,5,4,5,6,5,252,4,13,66,5,8,5,92,13,16,17,136,5,14,7,42,5,100,9,14,5,4,9,18,9,4,9,120,5,14,11,14,7,18,5,96,5,26,5,34,5,10,9,116,5,26,7,22,5,84,13,18,11,18,15,34,9,108,5,38,5,6,5,84,5,22,27,6,23,38,108,5,34,5,4,5,88,5,10,19,14,19,18,7,34,5,108,9,26,5,92,5,10,7,10,7,26,7,54,5,120,5,18,5,92,5,10,7,46,7,46,5,128,17,56
spot: db 6,17,245,95,255,245,93,87,127,245,87,127,245,223
hilltop: db 16,3*2,0x9, 0x33, 0x9, 0x8, 0xD, 0x1B, 0xD, 0x1C, 0x19, 0x14
ball: db 8,17,80,5,244,31,253,127,253,127,249,127,249,127,228,31,80,5
pipe0: db 64,5,0x90,0xFA,0xAA,0xAE,0xFF,0xFF,0xBB,0x06,0xA9,0xAF,0xAA,0xEB,0xFF,0xFF,0xBB,0x6B,0x90,0xFA,0xAA,0xAE,0xFF,0xFF,0xAE,0x06,0xA9,0xAF,0xAA,0xEB,0xFF,0xFF,0xEF,0x6A
pipe1:db 32,4,8,113,8,129
pipe2:db 32,12,5,23,26,79,9,122,133
qbrick: db 16,33,85,85,85,85,254,255,255,127,222,255,245,119,254,191,246,127,254,191,254,127,254,255,245,127,254,191,246,127,254,191,86,127,254,215,106,127,254,218,107,127,254,218,107,127,254,90,233,127,254,171,250,127,222,255,255,119,254,255,255,127,168,170,170,42
bricks: db 8,16,33,14,5,30,5,30,5,18,33,30,5,30,5,30,5
door: db 16,32,0xFD, 0xFD, 0x89, 0x6, 0x39, 0xA, 0x39, 0x6, 0x41, 0xA, 0x31, 0x6, 0x5, 0xE, 0x29, 0xA, 0x5, 0x16, 0x19, 0x12, 0x5
cren: db 16,17,213,255,255,85,234,0,192,170,234,0,192,170,234,0,192,170,234,0,192,170,234,0,192,170,234,0,192,170,255,0,192,255
block: db 16,32,61,6,7,53,6,5,11,45,6,9,15,37,6,13,19,34,17,19,34,17,19,34,17,19,34,17,19,34,17,19,34,17,19,34,17,19,34,17,15,6,35,17,11,6,43,13,7,6,51,9,6,59,5
rocks: db 16,33,86,149,87,149,171,106,171,90,171,127,171,106,251,85,171,106,95,170,173,106,165,170,173,106,171,170,182,106,171,170,182,106,171,170,182,106,171,170,246,127,171,170,102,149,171,170,118,106,171,170,182,106,171,170,182,106,171,170,182,106,254,255,231,191
fluff: db 8,10,11,     19,11,11,       27,10,31,       36,11,21,    11,1,34,    23,1,14,       41,1,24
pa: db 28,3,38,4,46,5,57,5,163,3,179,3
dba:db 21,5
qb: db 16,21,23,78,106,109,112,170, 21,9
qb2: db 22,94,109,129,130, 27,5
ba: db 20,22,24,77,79,94,100,101,118,129,130,168,169,171  , 27,9
ba2: db 80,81,82,83,84,85,86,87,91,92,93,121,122,123,128,131,0
pyr: db 137,5*2+1,140,5*2,151,5*2+1,152,5*2+1,155,5*2,188,9*2+1,189,9*2+1,198,4
ground: db 69,2,86-69-2,3,153-86-3,2,256-153-2,0
copy: db 202,2+5*16,26,26,24,26,26,   202,3+5*16,26,26,28,26,26,    202,4+5*16,29,30,30,30,29,   203,5+3*16,31,26,25,  203,6+3*16,29,29,29, 198,12+16,20
temp: rb 256*48
tiles: rb 34*16*16
image:

次佳解决方案

Javascript minified(*):1285 1258 1253 1205 1186 1171个字符

(*)根据xem的建议,使用Closure,RegPack和ObfuscaTweet进行细化

Unicode版本的大小为4549字节,没有ObfuscaTweet(仅限Closure和Regpack),大小为2251字节。

历史:

1285 – > 1258:变量A为48(thx @hsl),合并了一些for循环,合并mt()mu(),使用瓦片索引而不是瓦片字符串,优化png与PNGOUT

1258 – > 1253:合并了一些for循环;将mt()改名为r();删除不必要的大括号;变量B为16;定义16个未使用的CSS精灵(用A替换32);显示1个未使用的行(用B替换14);删除功能e();缩短t()g()c();尽可能使用for(i=0;i<n;)f(i++)代替for(i=0;i<n;i++)f(i)

1253 – > 1205:将身体样式移动到CSS部分,而不是<body style=...>;用f调用替换了一些for循环;优化功能rq; </head><body>似乎是不必要的,<html><head>也是;功能t(i)用于CSS映射删除; CSS名称b0 .. b31代替a .. zaa .. ff

1205 – > 1186:功能n更名为N;新增功能n,其操作在带有delta编码的阵列上

1186 – > 1171:山丘和经线可随时绘制”big”,下部由石块覆盖;对云和灌木使用d;删除了一些不必要的分号

这是一个程序性的尝试。有各种各样的图案,其中一个魔术数字是48(云层,灌木丛和山脉之间的瓦片间隙)。 tileset被编码为Base64数据url字符串,并用作CSS样式表。在Javascript中,212×14数组m填充有tile索引。有关详细信息,请参阅已注释的未最终版本。

适用于Chrome 38(Ctrl + T为新标签,Ctrl + Shift + J为JavaScript控制台,粘贴代码)和Firefox 33(如果用HTML JavaScript标签包装)。还有一个JS bin version

还有一些优化空间,我会发布更新,如果一些JS /CSS /HTML人可以建议优化/更正,这将是很好的。

精缩:

eval(unescape(escape('𩡯𬠨𧰽𙰠𨱬𨑳𬰽𠁹𚰫𚡗𚱸𙠩𞰣𘱦𘐽𜀻𨁦𫱲𚁟𘱟𪑠𧠣𫠨𦰟𛀴𗠩𮰝𝐳𗀬𝰛𚁡𖡦𭑮𨱴𪑯𫠠𖐨𜠘𘱧𖀗𖠬𨠖𛁥𕐮𭁯𤱴𬡩𫡧𚀔𚀱𔰣𬠓𞀒𘱎𔐚𚰐𮱢𨑣𪱧𬡯𭑮𩀏𛀳𓠞𚐬𩀌𭰨𘠼𒰬𜀣𒐫𚰩𒀟𨐫𜠱𑱁𠑁𠐆𚱩𚡁𑐬𜐄𕠕𗐃𛀲𐠩𯐙𐑗🐲𜐲𞱁🐴𞀻𠠽𜐶𞱭👛𧐻𖑷𖠝𩁯𨱵𫑥𫡴𛡷𬡩𭁥𖠁𣠖𗑭𦱡𧐽𘡢𘠫𨠔𐑮𕠝𮡠𧰤𘁩𫠠𨐩𮠫👡𦰤𧐬𣠨𮠬𨠁𩠃𧱫👡𞱫🀽𨐫𨠻𚑎𚁫𚰫𕐁𩰃𧱸👡𙑗𞱸🀽𨠥𥰻𮀈𧱹👡𛱗𯀰𞱹🁢𛱗𯀰𞰩𣠨𙠕𐑣𐱎𖠕𘐐𜐬𨠭𜐕𚰱𔐐𨠫𜐕𚰲𐑤𐱣𕠕𘱣𔁗𛁢𕐫𜐶𐑰𖠝𣠐𜠬𞀇𜰂𜐱𧐂𜰇𝀂𜐱𐡝𐠴𑰵𐠱𜱝𐠵𔐐𝀲𝠬𞐁𬐚𗑎𖠄𜀑𔀱𑀱𘱬𔁗𓠂𝠣𫀐𜠱𜰎𐠷𐑲𕠝𧱪𨀴🡪𞱪𒁦𔁢𚠨𜰭𪠩𚱪𚡗𛁪𛀰𐑬𐱟𪱠𪰼𨠻𪰈𣠐𪰪𥰕𚑽𩠨𜀂𞐶𝰛𧠴🡩𞱩𒁤𖀳𜐅𑀌𖀴𞀅𐠌𚀴𝐱𑐎𓀨𝀳𜠅𑀌𖀳𝀳𑐎𑀷𚐬𩀘𜰵𝐅𑀄𝰩𛁤𖀳𝰳𑐂𑀷𘱤𚀶𜠴𑀞𔐘𗀹𑀹𗰸𝰰𖰲𑀵𐠰𑀛𜰴𛀵𐠬𝐵𐠸𓠎𛀵𞁝𓠡𚀹𜠸𖰂𘐨𞐳𞐂𐠡𚀹𝠹𐠂𗰹𝰶𓠛𜰷𐠂𛀜𐠄𝐬𝠄𞀄𜐄𓠸𑀂𧐂𔐓𞐰𜀬𠠗𜰲𜠂𗀵𛁂𕰳𜠵𐠜𞀬𠠡𔰶𞀷𐠄𜰑𔰸𞐹𐠹𔐓𞐰𜐎𜐡𖀱𜐰𗠄𜰡𖀱𜐱𐠄𝐑𖀳𜠴𑀴𔐘𗀶𓠰𧠵🡩𞱩𒁰𔰹𜀸𑐩𛁰𖀱𜰵𑐣𬐓𝰴𜠣𬐓𝰜𘱱𔰹𝀶𘱱𖀱𝀸𘱱𖀲𞀳𘱱𖀲𞐹𔠳𜀄𔠴𝀄𔠷𝰄𘱲𔰰𜰳𑀒𜰶𒑲𔰸𝐱𒑧𔰸𞀱𐠵𜠰𒑬𔰰𜰷𗠉𫀓𞀴𞀞𒑬𔰸𞀵𗠉𣠨𝀱𜀄𜠣𫀨𝠲𜠬𞐂𞀑𖀜𜀉𩠘𝐴𝀞𜠳𑀗𝠱𜰂𞀲𝠛𕰶𜰰𐠸𝀴𖰗𝠹𝰂𞐱𜀛𘰋𬱴𮑬𩐾𨡯𩁹𮱷𪑤𭁨𞠳𝀰𜁰𮁽𩁩𭠏𞡵𬡬𚁤𨑴𨐺𪑭𨑧𩐯𬁮𩰻𨡡𬱥𝠴𛁩𥡂𣱒𭰰𢱇𩱯𑡎𤱕𪁅𥑧𠑁𠑑𑡁𩱂𠑍𑡐𪀷𭡘𑡇𜑂𣑖𡑖𨱬𤁷𑡁𬑁𡁉𥁁𮑁𜁂𡀸𛱐𮠸𭡌𡀸𫑄𩰸𭡐𮑑𥱌𣁕𠑁𠑃𭱫𫁅𤑖𤠴𦁲𥱗𤰴𬡪𣑂𠱇𦁣𮁪𬡦𢱪𩐲𜱨𠐴𭱒𢡎𭁊𞁁𡑭𪐴𢡳𥁕𡀷𬁨𩀹𩱫𠱏𤁓𥱎𝑏𪑒𭁴𬱸𞁸𡱊𜡃𢱰𪠹𞑓𢡣𥡏𥰸𨡤𭠫𫑩𢁤𚱕𝑖𩡸𤡡𤑄𡐯𮐶𜑪𮠹𜑆𬑰𢁲𡡓𤁢𛱲𡡒𨱴𦁅𥰸𢱆𝠶𞁅𜰱𨠫𭰯𣁇𚱂𠑏𢑘𠡏𫱨𝁵𡁘𜑣𝁉𫑃𣁉𥡆𮁣𫑡𡑋𨡓𣑙𨰴𡡘𥱺𞁑𠑃𢱸𣁆𠡋𮑑𣁓𜀲𦑃𨑁𪱅𨡁𤐴𠱡𠡪𛰯𡱵𥡊𩱁𣡅𤱮𬡹𤡧𠡌𬑪𦡌𬑵𮑸𢡁𪀹𬡸𞑇𢑅𭁇𢱣𭱋𪀶𫠸𢀫𤐲𡰱𡁷𤑡𦑧𡡙𢡓𠱐𚱓𤁯𜁖𢱚𚱈𪱫𠑪𜑗𩱣𡁲𩐵𞁉𥑃𣰲𢡌𠑳𫱐𥐴𢠳𡁭𡁌𦑭𩱉𝑍𢑎𞁄𨠶𞁱𡑁𠐶𦀫𫁋𬀲𨱔𭱂𩡎𝁉𤰯𡁧𤱹𦐯𪡥𝀱𜡧𝁥𬠰𤡁𣀫𚱐𬡶𤡙𩐯𫡨𩑙𥁧𡑧𣱑𤱳𥁑𠱏𥑩𭱌𥱋𥑘𡡔𨱩𫡁𤑡𞁯𪁇𬡅𮑧𣡴𜑧𥱕𠑪𠱷𤱇𢡯𡰹𡡷𠱡𣱊𡡙𫁙𠑘𭱅𞁯𞑉𪁍𪡸𩡢𪡉𢐫𡑄𝡃𢁸𤑧𮁌𫱅𤱩𭡧𬰰𥱈𭡹𝀰𡱩𫱵𬡳𩁉𩱆𬱸𭑬𦑍𡁑𥱣𪱯𜁉𪑇𢑭𩱓𥱂𡑓𜀹𡡺𩁪𥱧𪀯𪡂𬑋𪑁𦁑𡡍𠱚𦀰𣱑𥑳𭱉𭑏𭑱𝑺𢁹𭱉𤑬𠑘𤠱𬁡𤁉𤀲𝑮𛱉𤡰𩀰𨑚𪑩𤡫𪑧𪁘𤑖𬁡𣱤𜠰𮠫𠐴𠡉𜱷𚰲𛱘𠡺𡁂𜱈𬱫𥑐𤁮𦑰𫱺𡱣𝐵𠑋𥑌𫱇𭱦𠱈𥁤𥑷𣁉𫑹𪑌𝁇𫱕𬡬𪱃𢑌𜡁𡡅𞁭𩱉𝐷𬱙𡑒𢑯𜱧𩁱𦁢𪡒𜱩𠱍𬐷𤑄𭑦𠑈𝱃𭁄𭁪𩱣𣑨𡑓𠑵𩡺𭑺𠑶𣑮𜡷𡑬𬱯𫑙𥁓𠐸𠑥𡡊𩑃𮡑𬁑𞁂𪱁𜰴𦡑𣑑𨑑𠡴𜡚𬀵𢡯𡑖𠑪𨡃𫱸𢁉𣑪𩱒𜁷𥀱𤑘𫱂𨑒𡁐𢡊𡁴𠑗𠠷𢡨𣱁𪁧𤑓𢑑𤑌𦡓𮡑𬡴𞁄𩑒𛱁𩑶𫰯𫡓𩱁𬁮𛱍𤑓𨑉𝱘𜁁𠡳𞁂𜡈𝡥𥑩𨐰𜠯𭁁𤁕𮡕𤱷𢑧𣐸𥁭𤁪𠑅𢁇𠡤𠑅𮐷𭁑𛱧𡑆𢱌𩁑𡑷𦑬𬱦𩱃𡡇𬡁𭑁𨑚𣑅𛱱𣑁𮑉𩑉𨡘𜡧𪡧𤑏𨑷𣡧𜡲𥠷𝁃𞑋𤐫𮁹𣡄𤑯𬱷𑡂𢡒𥐵𡑲𪱊𩱧𩰽🐩𯐢𧡩🁁𞱩𒁪👩𙑂𚠭𠠬𪰽𜐵🁩🰭𠠺𜀬𭰨𘠮𨠢𚱩𕀩𚰢𓰭𬁯𬱩𭁩𫱮𞠢𚱪𚰢𬁸𘀢𚱫𚰢𬁸𞱷𪑤𭁨𞠱𝡰𮀻𪁥𪑧𪁴𞠱𝡰𮀻𩡬𫱡𭀺𫁥𩡴𞱽𘠣𒰯𬱴𮑬𩐾𘠣𧱸𨁸🁗𞱸𒁻𒱳𬁡𫡀𨠰🠢𘱟𮑠𮐼𠠻𚐋𩁩𭡀𘠫𫑛𙡝𚰢🠼𛱤𪑶🠢𘰋𛱳𬁡𫠾𘠩𯐻𙰻𩰽𛱛𐐭𗱞𛑠𘐣𙡀𧐯𛡥𮁥𨰨𧰩𞰩𭱩𭁨𚁟𛡳𬁬𪑴𚁧𚐩𧰽𪡯𪑮𚁳𪁩𩡴𚀩𚐻𩑶𨑬𚁟𚐠').replace(/uD./g,'')))

未经确定和评论:

// map width
W=212;
// helper constants
A=48;B=16;
// array containing the map, generated at runtime
m=[];
function w(s){document.write(s)}
// set a map tile
function N(i,s){m[i]="b"+s.toString()}
function n(i,s){z=0;for($ in i){z+=i[$];N(z,s)}}
// set a row of map tiles (index a..a+b)
function f(a,b,s){for(k=a;k<=a+b;)N(k++,s);}
// set a block of map tiles (index a and b define upper left and lower right corner)
function g(i,j,s){for(x=i%W;x<=j%W;x++)for(y=i/W|0;y<j/W|0;)N(y++*W+x,s)}
// helper for clouds and bushes - j=1..3 sets map tiles to XYZ, XYYZ or XYYYZ
function c(i,j,a){N(i,a);f(i+1,j-1,a+1);N(i+j+1,a+2)}
// clouds/bushes
function d(i,j,a){c(i,j,a);c(i+W,j,a+16)}
// hill
function p(i){N(i+2,8);n([i+213,211],23);n([i+214,211,2],24);n([i+215,213],25);N(i+426,9)}
// warps
function q(i){N(i,10);N(i+1,11);l(i+W,3,26);l(i+213,3,27)}
// stairs - d=1 for upwards, d=0 for downwards
function r(i,d){for(j=0;j<4;j++)f(i+d*(3-j)+j*W,j,0);}
// set a column of map tiles (index i, height j)
function l(i,j,s){for(k=0;k<j;k++)N(i+k*W,s);}
// fill map with sky tiles
f(0,2967,7);
// clouds and bushes - some of the bushes will be overdrawn by blocks and the castle, so draw them first
for(i=0;i<4;i++){d(231+i*A,1,4);d(248+i*A,2,4);d(451+i*A,3,4);d(432+i*A,1,4);d(2343+i*A,3,17);d(2355+i*A,1,17);d(2373+i*A,2,17)}d(624,1,4);N(2539,19)
// '?' blocks
n([870,72,15,20,1,734,5,2,55,28,3,3,58],3)
// brick blocks and castle
f(928,7,2);f(939,2,2);f(969,2,2);n([976,3,737,2,2,53,2,15,6,18,11,1,38,1,2],2);N(1900,B);g(2322,2535,B);g(2325,2538,B);f(1687,2,13);N(1899,29);N(1901,31);f(2110,4,13);f(2111,2,15);N(2324,14);N(2536,30)
// big and small hills - one of the big hills will be overdrawn by the stairs, the small hills are big hills overdrawn by stone blocks
for(i=0;i<5;i++){p(1908+i*A);p(2135+i*A)}
// warps (often overdrawn by stone blocks), stairs and block below pole
q(1742);q(1753);q(1946);q(2148);q(2283);q(2299);r(1830,1);r(1844,1);r(1877,1);r(1033,1);r(1836,0);r(1851,0);g(1881,2520,0);l(1037,4,0);l(1848,4,0);l(1885,4,0)
// pole
N(410,12);l(622,9,28);N(2530,0)
// lower row of stone blocks
f(2544,423,1);
// gaps in stone blocks
g(2613,2826,7);g(2630,2844,7);g(2697,2910,7)
// HTML start and CSS spritesheet base (tileset PNG encoded as base64)
w("<style>body{width:3400px}div{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgBAMAAAAPh7vXAAAAG1BMVEVclPwAAAAAqADITAyA0BD8/Pz8vLD8mDg8vPyQWLLUAAACwklEQVR4XrWWS4rjMBCGXcxjrfKje23hA4wRJNtJ8AEmi4JsTUD7phd9gkCOPSWN5OiRttsx8xGJ2CKpj99SJcVOW8bdv+miHd+U5VfxRaQDE/y61jz91FqpHrFSPb/rFRctXEW8KF668E31b+w/LG+BAOIXBOoh4uDX1c4ImCLIVFxcmaEKbSMYc4FXWz8QACKxLFBKyQLS02YCaAkEbAQ4CaBj//GuVJgANESnryRgBLqjZLquyxJAh9rx9GIEtGKcwKh6n8H+Q2G1DwQaYgFYJSCP+SPo0VKZ+HkkAj1WgcDre58IUCO2JLAsoPU4J3DmDLYmgI5MIN8Db68qEAA6X+lKp2cTwBfN4IS/DgSyY/je412g4er0RAL++PrvRYe/nheYTgEgOQSsTQCOUiwLWKUXFTcinAQa8ohGrEygNt1gWUAjCwSGJoG9FwCaOJFYlYAXwE8o9IhMjxfbjII+ED6CHxQgxLoESivgs0WHvy40GioursdIgFsxulYMDQWcko0IiGImgSWBES09FzdjWgh/jBqKiAXQFMCZX0OQUswIuOuq5zHywIQlAXR1paPIP25n/IRpd0aZiiRkighXQVpaOd20z+A4BI3w+2/XBzDB3HskUPPnYpozGc55AKULoGwfCHTdUwLImyiL4GoUrlkCIL2AFE8mgI57sYERIo3gdqXbjR3iCMq7QDufAH7CtDtjgcMhESAufzuzAvMn2wElsomYTSA8AeFJeCzQpQ8BkA34ZQMQaQBt2Zp5JoEVAjbCoxHIMjgR0wT1QXoBaRDPJJDtAWB7JhOAhgQSIQQLZSzQrt8DeR/Aevo/nSgApn/MQSaI7X0ABs8B2H6eUia02/tAPUzUSwIgM8TmPjAEHGBdAEy7tQ/gEFKLdQEwYlsfgCFGrAuAaZME/qMAyIeIbX2gjgQOawNg2rV74C9KQ+xyNDQoswAAAABJRU5ErkJggg==)}")
// generate CSS classes 'b0'..'b31' for the 32 used tiles
// this actually generates 16 additional unused classes to reuse the constant A and save 1 byte
for(i=0;i<A;i++){j=(i%B)*-B;k=i>15?-B:0;w(".b"+i.toString()+"{background-position:"+j+"px "+k+"px;width:16px;height:16px;float:left;}")}
// some more HTML
w("</style>")
// body of HTML contains all tiles as <div> elements arranged in <span> columns
for(x=0;x<W;x++){w("<span class=b0>");for(y=0;y<B;){w("<div class="+m[y++*W+x]+"></div>")}w("</span>")}

第三种解决方案

Python3 1638 1576 1616 1513字节

581代码+ 932数据

code-golf,kolmogorov-complexity,graphical-output

↑这个顶部是原来的水平。中间是这个脚本产生的PPM。在底部是一个差异,这表明调色板和Map不完全一致!我把它归结为数据故障,而不是我的脚本;)

# 759808 is 212*14 tiles at 16*16 each - the size of the map
import lzma;B,E,R,X=bytearray,759808,range,16
D=B(lzma.decompress(open("i","rb").read())+B(E)) # put canvas on end of data array
i,P=8218,lambda x,y:8622+y*54272+x*X # 8622 is length of decompressed data
def Q(s,n,d): # copies a 16x16 tile from s to d
 # n is the stride for the source s, which is different for put and copy
 for m in R(0,256,X):e=d+m*212;D[e:e+X]=D[s+m*n:s+m*n+X]
for j in R(4): # there are 4 command sections
 j&=1;i+=1+j;r=D[i-1]<<8 # j is now truthy if this is a copy buffer
 for k in R(D[i]): # this many commands
  a,b,w,h,c,d=D[i+1:i+7];q=h>32 # unpack it; put doesn't use all these
  # do the put/copy
  for z in R(((a,h-32)[q],w*h)[j]):Q((D[(i+4+z,i+5)[q]]<<8,P(a+z%w,b+z//w))[j],1+211*j,
      (P(b+z,w),P(c+(z%w,w-z%w-4)[r&1],d+z//w))[j])
  i+=((3+a,5)[q],6)[j&1];r>>=1 # move i to next command
for y in R(2,11):Q(28<<8,1,P(198,y)) # special case flagpole
o=open("o","wb");o.write(b"P6 3392 224 255 ") # header for PPM
for c in D[8622:]:o.write(D[8192+c*3:][:3]) # decompress palette to RGB

(没有注释的字节数,line-unwrapped和第二级缩进是\t)

数据(base64编码粘贴;解码并保存为名为”i”的文件):

/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4CGtA2JdAACA3BlsBrac0zEPcSPZ/qSCuw0fuG0WYiRk
w+pNfoBEsFJBEXgxJ73nEPREKmuJUHyg+jhBTQcbUI0gChatJ7D6ZqYmLz4P34OFSxUMWF+aGhm2
+8mNqw264w0JIjW9ogeNpJX6pgH/xJ/D2qlfqfCuz0cOR1sPAAcMrue1y9joUaDauFLj8QhbExen
lQkUMfMePbMnn4nJ0aVXBeHdKIwSeFQdFz/Aj695kKi0x8+MXR84cpNh3U8y7deiyjbNyIgu7vLn
WBxzXhEtrV9svBETfQpxj2qYI11ALgWlhoxdoABE3ocVgE1Qo35dnoJe+1DJFvqIzFOoxSJEckUk
T89RIjARdA/Ax6UTiitivZp4EhM+xczasrm+2XFy68mA96xmEMKp9ZpoApNIU0ShMMW1Im0QFeuS
aCl43qJuintArMAeDiOlmkbDNzMzHZIgDFeklUnnKG9xHXPQXNQVyJ9I7z+rLHh1VtuXDyAErKTL
VY/Xai2pIUlSt5H1KGEExdHu3O17XKbar11Jad6nFjDKOZFwamJQTFIG6dru2UXVJq29pGCnKLlB
lOmls4agigMI7QJ5K/Rzf15ZuIQ7U9MKJ3E4llbwqs6vDk+Ln/ceRVfl5Fm/Ne056ZLDp6VIf5zs
EMWra8UnjndkigqAyp8D62AcrPFIp9EdJmgiGzfhNCQ1JptRN/z01mNomtwVJfqeLTqgvRgXXG3P
8p+6s1rjEfblMBNyMxdYvJZXLE0wgu4xhH3fiNTT+RyTIJ1MZZ1zhksfe2SnNTbL2JYGven1WPfI
YP+M4NI/vpQ4bGsuJ8w//x01GpkTLfMZtZgBhx0dx1Wu9i0JY9hhtoI2/tGR4sNHfpSs7xD/Zz+7
6Z18z3AQn4dC7Trp0WndI/zS8eRZlRgKxA/lb09MZ87ugbXnm2+oBQFSLEtg/rqg398pDWx9W4Zk
6GeRTqvp9CJ9meMagUnGHKnAj+05PE0XgEXO6r9B8ltgoHf0+wXFevBHVupfiH9MApUxd0TPzv16
Y5Rfjxao0wLcIbxKMd3vtI1rCvOdq0OysWNrtcH9EBKjx9+CnGFBFZI9w9kCMJ8ZT0m9nsNYPelL
29KbQMt+K213+7o0MS3DxeGTHSW9CiEOTzNeqvsXN6IcIxjJIkgH8MuAAAAA5PpImPBeeH8AAf4G
rkMAALsE5byxxGf7AgAAAAAEWVo=

数据文件是我为此问题制作的自定义格式,并存储为LZMA。

首先,所有的32个瓦片序列化。在调色板中有9种颜色,这需要8219字节未压缩。 (我发现试图在4-bits-per-pixel上压缩瓷砖没有帮助压缩,我没有尝试和brute-force最好的排序,我可能在这里输了几点)

构成Map的是212×14 = 2968个块。

然后,重新创建Map的说明现在被编码。

首先是一部分”put”命令,在Map上的一个特定的x,y处放置一些tile-palette序列。由于有32个图块,我使用大于32而不是图块索引指定一个相同图块的运行。

然后是一部分”copy”命令,将当前Map的一些矩形复制到其他地方。有一个特殊的bit-mask标记如果副本应该镜像。

一个简单示例命令缓冲区:

16, # there are 16 put commands
3, # place 3 tiles
8,2, # dest x, y
4,5,6, # these three tiles
3, # place 3 tiles
8,3, # dest x, y
20,21,22, # these three tiles
5, # place 4 tiles
27,2, # dest x, y
4,5,5,5,6, # these five
...,
8, # bits set if copy reversed (high 8 bits of a uint16 mask)
14, # there are 14 copy commands
8,2, # src x, y
3,2, # w, h to copy
19,1, # dest x, y
1,9, # src x, y
3,2, # w, h to copy
16,10, # dest x, y
...,
13, # there are 13 put commands
...
7, # bits set if copy reversed (high 8 bits of a uint16 mask)
15, # there are 15 copy commands
...

(我说的很短,但实际上是完成整个Map所需的总命令缓冲区的一半;数据中绝大多数的字节是32个源代码块本身)

然后是”put”命令的第二部分,最后是另一部分”copy”命令。

因为这些可以互相覆盖,我可以构建我以后擦除或更改的副本部分。

我可以通过以下方式刮掉几个字节:例如 – 将其转换成小拷贝,并通过在gzip压缩的source-code上执行eval技巧,或者使用PNG(也就是使用image-specific过滤器进行DEFLATE)。但我喜欢这些事情,

第四种方案

Javascript,1069 1072 1024个字符(1957个字节)

RegPackedObfuscatweeted

eval(unescape(escape('𩡯𬠨𧰽𙰨𬱠𨀬𧡝𚑀𜐶𙡷𪑤𭁨𞠣𪱬𘐵𝠟𜠳𗠰𜀝𛀢𗀝𜀛𗀛𖡨𪐙🐢𘠻𩡯𬠨𖀩𚠦𚰢𬁸𕰠𬱴𮑬𩐽𧀧𕡁𠐕𗁡𨠔𫡯𬀓𖑩𪑪𔰒𬑲𔑮𫰹𫰐𝰷𓰏𝰎𜠲𓀢𛀋𒰶𗀉𬡥𭁵𬡮𒀩𚱒𚁃𧡛𑰋𞀜𑠎𝰅𒰱𑀕𕐃𠀬𝀩𚱃𧡛𝠜𐡦𭑮𨱴𪑯𫠠𐐁𤡞𭀩𮰈𘁮𩑷𘁁𬡲𨑹𚁴𚰱𚐮𪡯𪑮𨀩𯐁𨠨𫠩𮰈𘠼𩁩𭠖𨡡𨱫𩱲𫱵𫡤𞠠𭑲𫀨𩁡𭁡𞠻𨡡𬱥𝠴𛁩𥡂𣱒𭰰𢱇𩱯𐱎𤱕𪁅𥑧𕑁𤐃𠑧𠡁𣐃𤁨𝱶𦀃𡰱𠡍𥡅𥡣𫁐𭰃𠑱𠑄𢑔𠑹𠐰𠡄𞀯𤁺𞁶𣁄𞁭𡁧𞁶𤁹𤑗𣁌𥐕𠑃𭰡𡑑𥡒𝁘𬡗𥱓𝁲𪡍𠡃𡱘𨱸𪡲𩡋𪡥𗡨𠐴𭱒𢡎𭁊𞁁𡑭𪐴𢡳𥁕𡀷𬁨𩀹𩱫𠱏𤁓𥱎𝑏𪑒𭁴𬱸𞁸𡱊𜡃𢱰𪠹𞑓𢡣𥡏𥰸𨡤𭠫𫑩𢁤𚱕𝑖𩡸𤡡𤑄𡐯𮐶𜑪𮠹𜑆𬑰𢁲𡡓𤁢𛱲𡡒𨱴𦁅𥰸𢱆𝠶𞁅𜰱𨠫𭰯𣁇𚱂𠑏𢑘𠡏𫱨𝁵𡁘𜑣𝁉𫑃𣁉𥡆𮁣𫑡𡑋𨡓𣑙𨰴𡡘𥱺𞁑𠑃𢱸𣁆𠡋𮑑𣁓𜀲𦑃𨑁𪱅𨡁𤐴𠱡𠡪𛰯𡱵𥡊𩱁𣡅𤱮𬡹𤡧𠡌𬑪𦡌𬑵𮑸𢡁𪀹𬡸𞑇𢑅𭁇𢱣𭱋𪀶𫠸𢀫𤐲𡰱𡁷𤑡𦑧𡡙𢡓𠱐𚱓𤁯𜁖𢱚𚱈𪱫𠑪𜑗𩱣𡁲𩐵𞁉𥑃𣰲𢡌𠑳𫱐𥐴𢠳𡁭𡁌𦑭𩱉𝑍𢑎𞁄𨠶𞁱𡐕𝡘𚱬𢱰𜡣𥁷𠡦𣠴𢑓𛱄𩱓𮑙𛱪𩐴𜐲𩰴𩑲𜁒𠑌𚰫𤁲𭡒𦑥𛱮𪁥𦑔𩱅𩱏𤑓𬱔𤑃𣱕𪑷𣁗𢱕𦁆𥁣𪑮𠑑𨐸𫱨𡱲𡑹𩱎𭀱𩱗𥑁𪡃𭱓𡱊𫱇𞑆𭱃𨑏𢡆𦑬𦑁𦁷𡐸𫰹𢑨𣑪𮁦𨡪𢑉𚱅𡀶𠱈𮁑𩱸𣁯𡑓𪑶𩱳𜁗𢁶𮐴𜁇𪑯𭑲𬱤𢑧𡡳𮁵𫁙𣑄𤑗𨱫𫰰𢑩𡱉𫑧𤱗𠡅𤰰𞑆𮡤𪡗𩱨𛱪𠡱𢱩𠑘𤑆𣑃𦡘𜁏𤑕𬱷𢑵𣱵𬐵𮡈𮑷𢑑𫁁𦁒𜑰𨑐𢑐𜠵𫠯𢑒𬁤𜁡𦡩𪑒𪱩𩱨𦁑𥡰𨑏𩀲𜁺𚱁𝁂𢐳𭰫𜠯𦁂𮡄𠠳𢁳𪱕𤁐𫡙𬁯𮡇𨰵𝑁𢱕𣁯𡱷𩡃𢁔𩁕𭱌𢑭𮑩𣀴𡱯𥑲𫁫𠱉𣀲𠑆𡐸𫑧𢐵𝱳𦑅𤡉𫰳𩱤𬑘𨡪𤠳𪑃𣑱𝱑𡁵𩡁𢀷𠱴𡁴𪡧𨱍𪁅𤱁𭑦𮡵𮡁𭡍𫠲𭱅𫁳𫱭𦑔𤱁𞁁𩑆𢡥𠱺𤑰𤐸𠡫𠐳𝁚𤑍𤑡𤑂𭀲𦡰𝑊𫱅𥡁𪡢𠱯𮁈𢑍𪡧𤠰𭱔𜑑𦁯𠡡𤡄𤁊𢡄𭁁𥱂𝱊𪁏𠑨𩱑𤱉𤑑𣁚𤱺𤑲𭀸𡁥𤠯𠑥𭡯𛱮𤱧𠑰𫠯𣑑𤱡𢐷𦀰𠑂𬰸𠠲𢀶𩑕𪑡𜀲𛱴𠑐𥑺𥑓𭱉𩱍𞁔𫑐𪡁𡑈𡱂𩁁𡑹𝱴𤐯𩱅𡡋𣁤𤑅𭱙𫁳𩡧𠱆𡱲𠑵𠑡𦡍𡐯𬑍𠑹𢑥𢑢𦀲𩱪𩱑𣱡𭱎𩰲𬡖𝰴𠰹𢱑𚱸𮑎𡁑𫱳𭰃𠡊𤡕𝑅𬡫𢠩𛐢𚰨𫠥𙠗𘀭𘠫𚁮𛰦𯀰𕰻𘰦𬁸𞱨𩑩𩱨𭀺𙡰𮀻𩡬𫱡𭀺𫁥𩡴𯑜𙰾🀯𩁩𭠾𘡽𐑍𨀩𮱭𖁟𘁩𫠠𬰩𫐫👢𚁰𨑲𬱥𢑮𭁠𦱟𧐬𜰲𚐩𞰈𘁭𯐁𠱞𨐩𮱣𖀤𘁩𫠠𨐩𨰫🐤𙐲🱍𚁡𦰤𠀺𤡞𨑛𙁀𞰈𘁣𯑤𫱣𭑭𩑮𭀮𭱲𪑴𩐨𘠼𨡯𩁹𕠣𜰳𞐲𬁸𧀧🠢𚱒𨀽𨠨𝰩𛀲𜐲𑰱𞐜𝀟𑀴𗀴𝐟𒰸𐡣𑀳𧐇𞀜𝀟𑠡𫐅𝰴𝐵𗰅𘑬𫐋𞀂𬰷𝀟𒰹𧐇𞀜𘑭𑀶𗀡𫁬𫐄𝠂𬰷𘑭𒰳𜐜𜰋𝐷𗀌𓀌𓀎𓀞𑀴𗀳𑀱𗀌𜠅𗠳𜠋𗰜𗐆𬰋𜠝𖠆𬰄𞐹𖠰𑡳𑀹𞀚𗐆𬰅𩁤𩀋𓀜𜰎𗠞𜠋𜠱𕀋𞐔𑀸𗀞𜠄𝀜𜠅𝰲𑐷𜰏𜰏𜰅𝰲𑀰𗀌𒐰𓰰𑀰𗀝𓰰𑀲𗀌𜰲𑀲𖠛𑡳𑑴𩱶𑠸𒰳𝐔𒐑𓰸𒐑𒰳𞐜𞀋𜰷𗀝𓰝𑐸𓠛𓰝𒰲𝠚𖰰𑐸𓡳𓡤𩡦𩡤𒐓𑀳𗀸𑀰𕀆𔐉𔐷𔰋𝐜𔐉𞀋𜰱𗀓𑀳𗀸𒰲𜐚𓰛𓰓𝰛𜀏𖰎𞀷𨑢𑀴𕀷𖰛𗐎𔰏𬰎𩱧𩑧𩰏𞀏𔁰𒐒𑐙𪠏𔐆𔐷𖑩𪠷𔐐𬀅𔐒𑐙𪠄𝐜𖑩𪠎𔁰𒐒𒰴𗀙𪠄𜠚𜁩𪐛𜀐𖰝𓰛𜁪𔰑𓰙𪠋𞐜𔐛𖰛𓰐𬀷𜀎𩱧𭑧𩱪𔰷𘡀𚱒𚁃𚁢𚀱𚐬𦰶𞐜𓰄𝐜𓠋𝠴𗀏𒰵𝱀𛀲𚐩𞰧𞱧🐯𦰁𛐟𘐣𙡀𧡠𧐯𛡥𮁥𨰨𧰩𞰩𭱩𭁨𚁟𛡳𬁬𪑴𚁧𚐩𧰽𪡯𪑮𚁳𪁩𩡴𚀩𚐻𩑶𨑬𚁟𚐠').replace(/uD./g,'')))

无模糊的代码

我隐藏了这段代码,因为下面有一些非常强硬的代码。



function R(s,t){return new Array(t+1).join(s)}
function b(n){return"<div style='background: url(data:;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgBAMAAAAPh7vXAAAAG1BMVEVclPwAAAAAqADITAyA0BD8/Pz8vLD8mDg8vPyQWLLUAAACwklEQVR4XrWWS4rjMBCGXcxjrfKje23hA4wRJNtJ8AEmi4JsTUD7phd9gkCOPSWN5OiRttsx8xGJ2CKpj99SJcVOW8bdv+miHd+U5VfxRaQDE/y61jz91FqpHrFSPb/rFRctXEW8KF668E31b+w/LG+BAOIXBOoh4uDX1c4ImCLIVFxcmaEKbSMYc4FXWz8QACKxLFBKyQLS02YCaAkEbAQ4CaBj//GuVJgANESnryRgBLqjZLquyxJAh9rx9GIEtGKcwKh6n8H+Q2G1DwQaYgFYJSCP+SPo0VKZ+HkkAj1WgcDre58IUCO2JLAsoPU4J3DmDLYmgI5MIN8Db68qEAA6X+lKp2cTwBfN4IS/DgSyY/je412g4er0RAL++PrvRYe/nheYTgEgOQSsTQCOUiwLWKUXFTcinAQa8ohGrEygNt1gWUAjCwSGJoG9FwCaOJFYlYAXwE8o9IhMjxfbjII+ED6CHxQgxLoESivgs0WHvy40GioursdIgFsxulYMDQWcko0IiGImgSWBES09FzdjWgh/jBqKiAXQFMCZX0OQUswIuOuq5zHywIQlAXR1paPIP25n/IRpd0aZiiRkighXQVpaOd20z+A4BI3w+2/XBzDB3HskUPPnYpozGc55AKULoGwfCHTdUwLImyiL4GoUrlkCIL2AFE8mgI57sYERIo3gdqXbjR3iCMq7QDufAH7CtDtjgcMhESAufzuzAvMn2wElsomYTSA8AeFJeCzQpQ8BkA34ZQMQaQBt2Zp5JoEVAjbCoxHIMjgR0wT1QXoBaRDPJJDtAWB7JhOAhgQSIQQLZSzQrt8DeR/Aevo/nSgApn/MQSaI7X0ABs8B2H6eUia02/tAPUzUSwIgM8TmPjAEHGBdAEy7tQ/gEFKLdQEwYlsfgCFGrAuAaZME/qMAyIeIbX2gjgQOawNg2rV74C9KQ+xyNDQoswAAAABJRU5ErkJ)-"+(n%16)*16+"px -"+(n/16|0)*16+"px;width:16px;height:16px;float:left}'></div>"}
function M(s){m="";for(_ in s)m+=b(parseInt(s[_],32));return m}
function C(s,a){c="";for($ in a)c+=$%2?M(a[$]):R(s,a[$]);return c}
O="<body style='width:3392px'>";
O+=R(s=b(7),212);
O+=R(C(s,[19,"456",14,"4556",8]),4);
O+=C(s,[6,"c",13]);
O+=R(C(s,[8,"456",8,"klm77777455567777kllm",8]),4);
O+=C(s,[6,"s7456",9]);
O+=R(C(s,[8,"klm",16,"klllm",16]),4);
O+=C(s,[6,"s7klm",31,"3",57,"222222227772223",14,"3",11,"22277772332",56,"00",8,"s",200,"000",8,"s",199,"0000",8,"s",198,"00000",8,"s7777ddd",22,"377723232",21,"ab",9,"ab",18,"232",14,"2777772777773773773777772",10,"22",6,"0770",10,"00770",12,"2232",12,"000000",8,"s7777tgv",8,"8",35,"ab",6,"qr778",6,"qr",39,"8",37,"007700777787770007700",26,"000000077778777s777dfffd",6,"nop",13,"8",10,"ab",8,"qr",6,"qr7nop",5,"qr",6,"8",31,"nop",13,"8",21,"0007700077nop700007700077787ab",14,"ab700000000777nop77s777ggegg77877no9op",6,"hiiijnop7777hij77qr",8,"qr7hiij7qrno9op7777qrhiiijnop7777hij",15,"hiij777no9op",6,"hiiijnop",4,"hij",12,"0000ii0000no9o00000770000jnopqr77hij",9,"qr00000000077no9op70777gguggjnop7"]);
O+=R(C(b(1),[69,"77",15,"777",64,"77",57]),2);
document.write(O);

不高兴的代码



function repeat(s, t) { var S=s; while(t-- > 1) S += s; return S; }
function block(n) { return "<div style='background: url(data:;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgBAMAAAAPh7vXAAAAG1BMVEVclPwAAAAAqADITAyA0BD8/Pz8vLD8mDg8vPyQWLLUAAACwklEQVR4XrWWS4rjMBCGXcxjrfKje23hA4wRJNtJ8AEmi4JsTUD7phd9gkCOPSWN5OiRttsx8xGJ2CKpj99SJcVOW8bdv+miHd+U5VfxRaQDE/y61jz91FqpHrFSPb/rFRctXEW8KF668E31b+w/LG+BAOIXBOoh4uDX1c4ImCLIVFxcmaEKbSMYc4FXWz8QACKxLFBKyQLS02YCaAkEbAQ4CaBj//GuVJgANESnryRgBLqjZLquyxJAh9rx9GIEtGKcwKh6n8H+Q2G1DwQaYgFYJSCP+SPo0VKZ+HkkAj1WgcDre58IUCO2JLAsoPU4J3DmDLYmgI5MIN8Db68qEAA6X+lKp2cTwBfN4IS/DgSyY/je412g4er0RAL++PrvRYe/nheYTgEgOQSsTQCOUiwLWKUXFTcinAQa8ohGrEygNt1gWUAjCwSGJoG9FwCaOJFYlYAXwE8o9IhMjxfbjII+ED6CHxQgxLoESivgs0WHvy40GioursdIgFsxulYMDQWcko0IiGImgSWBES09FzdjWgh/jBqKiAXQFMCZX0OQUswIuOuq5zHywIQlAXR1paPIP25n/IRpd0aZiiRkighXQVpaOd20z+A4BI3w+2/XBzDB3HskUPPnYpozGc55AKULoGwfCHTdUwLImyiL4GoUrlkCIL2AFE8mgI57sYERIo3gdqXbjR3iCMq7QDufAH7CtDtjgcMhESAufzuzAvMn2wElsomYTSA8AeFJeCzQpQ8BkA34ZQMQaQBt2Zp5JoEVAjbCoxHIMjgR0wT1QXoBaRDPJJDtAWB7JhOAhgQSIQQLZSzQrt8DeR/Aevo/nSgApn/MQSaI7X0ABs8B2H6eUia02/tAPUzUSwIgM8TmPjAEHGBdAEy7tQ/gEFKLdQEwYlsfgCFGrAuAaZME/qMAyIeIbX2gjgQOawNg2rV74C9KQ+xyNDQoswAAAABJRU5ErkJ)-" + (n%16) * 16 + "px -" + (n/16|0) * 16 + "px; width: 16px; height: 16px; float: left; }'></div>"; }
function blocks(s) { var S=""; for(var i in s) S += block(parseInt(s[i], 32)); return S; }
var output = "<body style=width:3392px>";
output += repeat(block(7), 212);
output += repeat(blocks("777777777777777777745677777777777777455677777777"), 4);
output += blocks("777777c7777777777777");
output += repeat(blocks("7777777745677777777klm77777455567777kllm77777777"), 4);
output += blocks("777777s7456777777777");
output += repeat(blocks("77777777klm7777777777777777klllm7777777777777777"), 4);
output += blocks("777777s7klm777777777");
output += blocks("777777777777777777777737777777777777777777777777777777777777777777777777777777772222222277722237777777777777737777777777722277772332777777777777777777777777777777777777777777777777777777770077777777s7777777777777");
output += blocks("777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777700077777777s7777777777777");
output += blocks("777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777000077777777s7777777777777");
output += blocks("777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777770000077777777s7777ddd777777");
output += blocks("7777777777777777377723232777777777777777777777ab777777777ab7777777777777777772327777777777777727777727777737737737777727777777777227777770770777777777700770777777777777223277777777777700000077777777s7777tgv777777");
output += blocks("77877777777777777777777777777777777777ab777777qr778777777qr7777777777777777777777777777777777777778777777777777777777777777777777777777700770077778777000770077777777777777777777777777000000077778777s777dfffd77777");
output += blocks("7nop777777777777787777777777ab77777777qr777777qr7nop77777qr77777787777777777777777777777777777777nop777777777777787777777777777777777770007700077nop700007700077787ab77777777777777ab700000000777nop77s777ggegg77877");
output += blocks("no9op777777hiiijnop7777hij77qr77777777qr7hiij7qrno9op7777qrhiiijnop7777hij777777777777777hiij777no9op777777hiiijnop7777hij7777777777770000ii0000no9o00000770000jnopqr77hij777777777qr00000000077no9op70777gguggjnop7");
output += repeat( repeat(block(1), 69) + blocks("77") + repeat(block(1), 15) + blocks("777") + repeat(block(1), 64) + blocks("77") + repeat(block(1), 57), 2);
document.write(output);

我首先使用@ schnaader的最小化数据URI将瓷砖制成精灵。 0 ~ v(在31中为0〜31)表示每个瓦片。

我手动将Map转换成瓷砖。该数据每行有212个字符。

然后用repeat()替换重复字符(如7(sky)和1(ground))。

我发现7和一些块,并重复了另一个7模式。所以我做了另一个功能使其紧凑。您可以在无模糊的源代码中看到它。

最后我RegPacked,并欺骗我的2341字节的高尔夫球代码。

这是非常有趣的挑战。谢谢!感谢@xem的更多技巧。

第五种方案

JavaScript:3620(ouch)3429 3411

Updates

  • 更新#1:删除var定义,并将变量声明放在第一次使用的括号内。删除了getElementById(),因为它也可以通过ID作为可变的加载。使用cloneNode()代替createElement('CANVAS')。从xMx更名为M。删除了缩放功能:((在示例中仍然可用))向扩展代码添加了一些注释(该代码不会随着删除更新),下面的行(“Mini code”)是。)

  • 更新#2:删除主函数M()作为一个整体,让代码运行在根。这将需要将代码放置在加载包装器或文档的末尾。

  • 更新#3:添加统计信息。

迷你代码:

K=126,f=['#000','#c84c0c','#fc9838','#00a800','#80d010','#fcbcb0','#3cbcfc','#fcfcfc'],X='Å=!15d>KIRiE%>?D^?C^FVNBTJ@M^>>]ANtN?ZCW]@QM4Gb1>EVWEZAEZN@VfMI?MPckVAwNEZWNV>Q]@YT2n6d@%vN4Gb@MABM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@U`>@UJ?@U`?@Uf@U`>@UCXUBP3qF%U@PEUBH3qH%UNIqD%UNAqP%UBQG3bUEQ&&';'B%?KAG@B@@p"%2_>>AC%]>j>H>G2e%O2O1DAY>I>W>6GA9Q>J>:K:%?A?%P>E1E>A>?>A?F>H1D>P1C>20B>@AF1D19,&GC1@>B1%?@1?17,&,6,5,8,4,3,>12,0,1,'.match(/../g).forEach(function(v){X=X[u='split'](String.fromCharCode(K--))[U='join'](v);if(K==92)K=91});eval(X[u]('*')[U]('f')[u](')')[U]('d')[u]('(')[U]('b')[u]('&')[U](']')[u]('%')[U]('[')[u]('#')[U]('}')[u]('!')[U]('{'));function e(k,d,i){for(s[Y]=k,i=0;i<d[L];)s.rect[G](s,d.slice(i,i+=4))}function _(d,i,q){for(S.width=R,i=0;i<d[L];++i,s.fill(),s.beginPath())F[q=d[++i][0]]?F[q](d[i]):e(f[d[i-1]],d[i])}F={$:function(d){_(Å[d[1]].concat(d.slice(2)))},b:function(d){_(Å[d[1]].slice().map(function(i,x){return(x=d[2].indexOf(i))>-1?d[2][++x]:i}))},f:function(d,i){for(s[Y]=f[d[1]],s.moveTo[G](s,d[2]),i=3;i<d[L];++i)s.lineTo[G](s,d[i])},d:function(d,x,y,g){for(s[Y]=f[d[1]],g=d[2],y=g>0?0:15,x=0;x<R;++x,y+=g)s.rect(x,y,1,1)}};R=16;c.width=3392;c.height=224;;S=c.cloneNode();c=c[G='getContext']('2d');s=S[G]('2d');c[Y='fillStyle']='#5c94fc';c.rect[G='apply'](c,[0,0,3392,224]);c.fill();for(k=0;k<Ø[L='length'];++k)for(_(Å[Ø[k]]),t=Ø[++k],i=0;i<t[L];i+=3)for(j=0;j<t[i+2]*R;j+=R)c.drawImage(S,t[i]*R+j,t[i+1]*R)

Blah blah:

–演示结束后。

使用canvas作为基础,试图解决这个问题。结束了约6000个字符,但经过一些虚拟(和一个自定义的压缩 – 同时也是微调和调整)我现在在这个数字。仍然很高,但再次质量很好;-)。

它还包括一个比例选项,xMx()的第一个参数,又名”main”函数。 1 =正常大小(如16位瓦片)。没有太多的调整空间,所以如果一个使用分数的一些瓦片不适合最好的一起。整数应该是可以的。 [1]

但是,警告,上升,快速地吃掉资源,并创造一个巨大的画布。 (全部都是一画一遍)当原来的宽度是3392像素时,它很快变得巨大。 [1]

[1]从更新#1开始,这已被删除。它在演示中存在。


统计:

  • Main code           :  870

  • Compression:

    • Main data       : 2176 (17,480 bits) 

    • Key             :  128 ( 1,024 bits) 

    • Code            :  236  

    • Whole she bang : 2540  

    • Decompressed data : 5608 (44,864 bits) 

  • Total   : 3410   [1]

[1]:+1字节,”;”之间,主/数据码之间。

压缩数据是一个数组,Ä,Â…和一个”object”,Ä,Â〜。 Ä,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,; Ä,Â~应该是一个数组â“但是我的代码开始与这样的东西:

var tiles = {
   brick: [
        ...
   ],
   qmark: [
        ...
   ],
};

最终也是如此。我可能会看到我是否无法解决这个问题。理想情况下,我将使用JSON而不是 eval()进行解析,但这不一定是这样的比赛。因为现在它不能被JSON解析,因为ID零件周围缺少引号。


Demo

这是一个小提琴,人们可以看到行动中的代码。小提琴中的代码已经有所扩展(并在世界各地添加了一些HTML /CSS样式⢓,但它的本身的形象是自我维持的。):

MARIOS WORLD

code-golf,kolmogorov-complexity,graphical-output


扩展代码:

扩展和(有点)重新排列的代码:

var D, C, c, S, s,   // Document, canvas and shadow canvas.
    R, F, Z, X, 
    Ø, Å,            // Due to the compression we have a couple of non-ascii
    K,               // variable names.
    L = 'length',
    Y = 'fillStyle',
    u = 'split',
    U = 'join',
    f = [
        '#000',    '#c84c0c', '#fc9838', '#00a800',
        '#80d010', '#fcbcb0', '#3cbcfc', '#fcfcfc'
    ]
;

/* ----------------------- data unpackeer and loader ------------------------ */
X='Å=!15d>KIRiE%>?D^?C^FVNBTJ@M^>>]ANtN?ZCW]@QM4Gb1>EVWEZAEZN@VfMI?MPckVAwNEZWNV'+
'>Q]@YT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3s4l>5gA6Nv8k>3W]4Y]5Q]'+
'4Ha5DWq>xQc6Lc7W]3Da4FX5HQq@xWc6Nc8I]3Pa4HX5DQq~19Qc9DPhDDhDHhDFhDEhDChDBhDJqu'+
'19mqE%Uf@U`>@UJ?@U`?@Uf@U`>@UCXUBP3qF%U@PEUBH3qH%UNIqD%UNAqP%UBQG3bUEQ&&';

K = 126;  // Key pos (char) counting down.
('B%?KAG@B@@p"%2_>>AC%]>j>H>G2e%O2O1DAY>I>W>6GA9Q>J>:K:%?A?%P>E1E>A>?>A?F>H1D>P'+
'1C>20B>@AF1D19,&GC1@>B1%?@1?17,&,6,5,8,4,3,>12,0,1,').match(/.{2}/g).forEach(
    function (v) {
        X = X[u](String.fromCharCode(K--))[U](v);
        if (K === 92)
            K = 91;
    }
);

/*
* Initially JSON, but got lost in compression work + a somewhat bad design
* on the obj. to begin with. Is eval, at least for now.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
try {
    eval(X
    [u]('*')[U]('f')
    [u](')')[U]('d')
    [u]('(')[U]('b')
    [u]('&')[U](']')
    [u]('%')[U]('[')
    [u]('#')[U]('}')
    [u]('!')[U]('{')
    );
} catch (e) {
    console.warn(e);
}


// Scaling function
function z(a) {
    return a.slice().map(
        function (v) {
            return v * Z;
        }
    );
}
// Tile painter "normal tiles"
function e(k, d, i) {
    for (s[Y] = k, i = 0; i < d[L];)
        s.rect.apply(s, z(d.slice(i, i += 4)));
}
// 
function _(d, i, q) {
    S.width = R;
    for (i = 0; i < d[L]; ++i) {
        s.beginPath();
        F[q=d[++i][0]] ? F[q](d[i]) : e(f[d[i-1]],d[i]);
        s.fill();
    }
}
F = {
    $ : function (d) {  // Expand a tile (e.g. add border on top
                        // of "normal" bricks as with the "in-air".
        _(Å[d[1]].concat(d.slice(2)));
    },
    b : function (d) {  // Replace colors. (Used for bushes.)
        _(Å[d[1]].slice().map(
            function(i,x){
                return(x = d[2].indexOf(i)) > -1 ? d[2][++x] : i;
            }
        ));
    },
    f : function (d, i) { // Free-paint (fill). E.g. "hill-sides"
        s[Y] = f[d[1]];
        s.moveTo.apply(s, z(d[2]));
        for (i = 3; i < d[L]; ++i)
            s.lineTo.apply(s, z(d[i]));
    },
    d : function (d, x, y, g) { // Diagonal lines.
        s[Y] = f[d[1]];
        g = d[2] * Z;
        y = g > 0 ? 0 : 15 * Z;
        for (x = 0; x < 16 * Z; x += Z, y += g)
            s.rect(x, y, Z, Z);
    }
};
// Main function.
function xMx(h, k, i, j, t) {
    Z = h || 1;
    R = 16 * Z;
    D = document;
    C = D.getElementById('m');              // Doc canvas
    c = C.getContext('2d');
    S = D.createElement('CANVAS');          // Memory canvas
    s = S.getContext('2d');

    C.width  = 3392 * Z;
    C.height =  224 * Z;
    c[Y] = '#5c94fc';
    c.rect.apply(c, z([0, 0, 3392, 224]));  // Blue sky (rest is tiles)
    c.fill();

    for (k = 0; k < Ø[L]; ++k) { // Loop coordinate array. This has fixed
        _(Å[Ø[k]]);              // order.
        t = Ø[++k];
        for (i = 0; i < t[L]; i += 3) {
            for (j = 0; j < t[i+2] * R; j += R)
                c.drawImage(S, t[i] * R + j, t[i+1] * R); // Apply tile.
        }
    }
}

xMx(); // Load main.

第六种方案

Python 1331 1326 1314 1272 1268 1217字节

(代码:219 214 202 186 182,数据:362 + 750 = 1112 363 + 723 = 1086 346 + 689 = 1035)

这里的想法是,我首先生成一个十六进制的Map,每个维度的大小,其中每个像素都通过平铺图中的索引着色。为了确保使用相同的托盘,我首先将给定的瓦片Map和Map组合成单个图像。从这个和瓷砖Map(两个minified png),我们现在可以重新生成原始Map。 (此过程的代码可以在提交代码下面看到)。应该注意的是,我将瓦片Map保存为文件”t”,并将生成的Map作为图像”m”

编辑:我开始探索瓦片的顺序如何影响压缩,为了探索,我产生了10000个随机排列,并用这个结果压缩它们:这一切都在一行中,因为这样减少了代码位。我尝试了不同配置(2 * 16,4 * 8)的类似的东西,但没有一个更好的平均结果。

code-golf,kolmogorov-complexity,graphical-output

假设png可以用更大的连续相似区域压缩得更好,我建立了一个可以让我移动瓷砖的工具,并且使用我认为是更连续的图像,我将瓷砖图像从750b下降到723。

编辑2:对于png实际工作的更多分析以及大量实验(仍在进行中),图像现在已经进一步压缩了。链接以下更新。稍后在完成后,我会再对此进行分析。

使用的新图像在这里:http://imgur.com/a/RgkXx

以下是在此过程中生成的其他图像:http://imgur.com/a/HXTGA,虽然有些是由于上述编辑而过时的。

import PIL.Image as I
O=I.open
t=O("t")
m=O("m").load()
o=I.new("RGB",(3392,224))
s=16
for i in range(2968):y=i/212;x=i%212;v=s*m[x,y];o.paste(t.crop((v,0,v+s,s)),(x*s,y*s))
o.show()

我写的减少Map的脚本是非常粗糙的,但是这里(由于上面的变化也可能是过时的):

from PIL import Image

blockSize = 16
combined = Image.open("combined.png")
tileImage = combined.crop((0,224,256,224+32))
w,h = tileImage.size

tiles = []
for y in range(0,h,16):
    for x in range(0,w,16):
        tiles+=[list(tileImage.crop((x,y,x+blockSize,y+blockSize)).getdata())]

referenceImage = combined.crop((0,0,3392,224))
w,h = referenceImage.size

mapImage = Image.new("RGB", (w/blockSize, h/blockSize))

colorScale = 256/len(tiles)

for y in range(0,h,16):
    for x in range(0,w,16):
        i = tiles.index(list(referenceImage.crop((x,y,x+blockSize,y+blockSize)).getdata()))
        mapImage.putpixel((x/16,y/16),(i*colorScale,i*colorScale,i*colorScale))

mapImage.save("map.png")

第七种方案

Perl 5 + PNG:689 + 593 = 1282

一个失败的尝试从基督徒的解决方案与Perl代码替换PNG压缩瓦片Map。最后是65字节更长。在输入上使用the same PNG tiles,并在输出上生成一个PNG。

用途:perl mario.pl <tiles.png >world.png

eval'+s/\d+(<?)(.+?)\1/$2x$&/ge'x2?$x|=$_:
map{/A/&&y'{}['Y';push@l,split"";y/D-IMNOY[|_@-_/EF@EE}JKLY~__@/;
s'@Y'YY'g;s'y@'yy'g;s'@E'DE'g;s'E@'EG'g}($x)x$_
for@z=qw(256@ 1
4<19@MNO14@MNNO8@<6@I 1
5<8@MNO16@M3NO16@< 2
22@X57@8T3@3TX14@X11@3T4@TXXT56@YY 3
203@3U 1
16@X3@TXTXT21@[|9@[|18@TXT14@T5@T5@X2@X2@X5@T10@2T6@Y2@y10@YY2@y12@TTXT31@QPS 1
5<2@H45@< 38@[|162@U3VU 1
5<17@H30@< 28@[|133@[|14@[|21@PPWPP 1
4<11@A3BC7@ABC15@ABBC3@<10@PPRPPC48@2<69Z2@15Z3@64Z2@101Z< 1);
$p=GD::Image;use GD;$f=new$p(3392,224);$k=newFromPng$p('-');
copy$f($k,map$_*16,$i%256,$i++>>8,31&ord,0,1,1)for@l;print$f->png

参考文献

注:本文内容整合自google/baidu/bing辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:gxnotes#qq.com(#替换为@)。

本文由《共享笔记》整理, 博文地址: https://gxnotes.com/article/189068.html,未经允许,请勿转载。
Go