one of those cool programs that you just have to share...

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
evilpaul
Baaaa!
Baaaa!
Posts: 811
Joined: Wed Sep 29, 2004 2:01 pm 0
Location: #ukscene, helsinki branch
Contact:

one of those cool programs that you just have to share...

Post by evilpaul »

a 256byte demo by picard of the exceed demo group. runs in dos/windows
http://www.scene.org/file.php?file=/par ... d-hell.zip
Image
believe me when i say that the screenshot does not do it justice! :)

if that raises your interest then check out some more here:
http://pouet.net/prodlist.php?page=1&ty ... er=thumbup



( and just for a bit of perspective.. the text above ( including the two urls ) takes up more space than the demo does ;)
User avatar
moosedude
Baaaaaaa!
Baaaaaaa!
Posts: 6209
Joined: Fri Nov 19, 2004 1:19 pm 0
Location: Craggy Island
Contact:

Post by moosedude »

Thats brilliant in just 256k !

I think the regular people in bleatings might wanna know about this ;)

01000101 01000100 01000111 01000101

http://www.redbubble.com/people/fotofill/ buy my photos!
User avatar
barry
Baaaa!
Baaaa!
Posts: 626
Joined: Thu May 27, 2004 6:52 pm 0
Location: London

Post by barry »

moosedude wrote:Thats brilliant in just 256k !
Nope, it's 1024 times smaller than that ;)
User avatar
skab
Baaaaaa!
Baaaaaa!
Posts: 3448
Joined: Sat Apr 27, 2002 1:53 am 0
Location: Barnyard, Ruhr area, Germany

Post by skab »

8O

Holy crap, to get something that small was hard on the C64. Big thumbs up for that!
User avatar
the2bears
Baaaaaa!
Baaaaaa!
Posts: 3686
Joined: Wed Oct 27, 2004 9:30 pm 0
Location: The City by the Bay
Contact:

Post by the2bears »

Very cool looking... going to check this out more at home!

Bill
the2bears - the indie shmup blog
User avatar
oNyx
Baaaaa!
Baaaaa!
Posts: 1652
Joined: Mon Sep 08, 2003 1:24 am 0
Location: de/fd

Post by oNyx »

8O
Mr Sheen
Baaa!
Baaa!
Posts: 182
Joined: Sat Nov 06, 2004 10:59 am 0

Post by Mr Sheen »

Holy crap: http://pouet.net/prod.php?which=3397

I found that one amazing.

Which! Brings me back to a little issue that has bothered me for many years. In that 256 byte space exists some real magic. Those same 256 bytes that make a swirling tunnel can also make a recursive structure that you spin through, and everywhere in the universe those same 256 bytes will do the same thing when executed on a computer.

In effect, the programmers have just "located" a 256-byte sequence that "does something"

I was wondering that, if I was to write a program that generated every possible 256byte sequence...and then try and run it...would it too come up with those programs? I.E., do they exist in the universe already? What other programs exists in that 256byte space that I could "randomly" generate and execute. How long would a super computer take to generate every possible 256byte sequence.

I've had similar thoughts before when it comes to images...arrays are fixed you see, any picture you see on a screen exists precisely with that value...IE, it has always existed, and always will, once you know its "value". So if you wrote a program to generate every possible 16x16 value, you would see some pictures that someone "else" had discovered. Extend that same image array up to say, 1024x768 in monochrome, and somewhere in that array space is a picture of a winning lottery ticket with a date on it...because its possible to photograph that ticket and therefore prove it exists, you just need to know the correct position in that array.

Mindblowing isn't it. But...its fact, it can be proved to be real, yet there's this strange reality surrounding it that almost says it can't be done, because there will be pictures in that array of hitler winning the war, or people with dogs heads. Would those be real or not?

Someone help me discover them. I want to find something random in that 256 byte space that actually executes and does something pretty.
User avatar
20thCenturyBoy
Baaaaa!
Baaaaa!
Posts: 1093
Joined: Fri Oct 01, 2004 8:16 am 0
Location: Perth, Australia

Post by 20thCenturyBoy »

Well the first 4 bytes will definitely need to be B0 13 CD 10 which puts the video card into VGA mode 13, so that only leaves 252 bytes to worry about.
So you'd need 252^256 sequences which is about 5 with 600 zeros after it. That can't be right can it?

But yeah, obviously every program that can ever be written exists already as a sequence of bytes. Maybe that's why Duke Nukem Forever is taking so long to create - they're just trying random sequences of gigabytes :D

You know if you want to fiddle you can open the .com with the debug command, and edit the bytes directly. You can also get a dissassembly. The hell.com file has the following sequence:

Code: Select all

1516:0143 DF440E                FILD    WORD PTR [SI+0E]
1516:0146 DE7404                FIDIV   WORD PTR [SI+04]
1516:0149
1516:014B DE4C5D                FIMUL   WORD PTR [SI+5D]
1516:014E DF5C0A                FISTP   WORD PTR [SI+0A]
so you could maybe change the FIMUL to FIDIV and see what happens, that kind of thing.
User avatar
bloid
Baaaaaa!
Baaaaaa!
Posts: 4082
Joined: Wed Dec 17, 2003 3:12 pm 0
Location: Mancuniana

Post by bloid »

Can you patent a sequence of bytes?
"What's there to lose?" said the general, selling our dead meat by the pound...
SiN
Baaaa!
Baaaa!
Posts: 850
Joined: Sat Dec 11, 2004 4:25 am 0
Location: Canada
Contact:

Post by SiN »

awesome stuff!

quick question (as i'll miss my bus if i make this any longer)

I've been taking a couse in assembly this semister ... MIPS asm and stuff about how to write compilers, etc. I REALLY enjoyed writing asm code ... and i'd like to try my hand at something like this.

can anyone point me in the right direction? which compiler to use? some x86 asm documentation. and basically, how do i get a mode13 screen up and how do i plot pixels on it?

cheers


SiN
User avatar
Dvorak
Baaaaaa!
Baaaaaa!
Posts: 4560
Joined: Wed May 08, 2002 7:37 am 0
Yahoo Messenger: d3dxquaternion
Location: Germany

Post by Dvorak »

Mr Sheen wrote:I was wondering that, if I was to write a program that generated every possible 256byte sequence...and then try and run it...would it too come up with those programs? I.E., do they exist in the universe already? What other programs exists in that 256byte space that I could "randomly" generate and execute. How long would a super computer take to generate every possible 256byte sequence.
Data is just data.
A sequence of 256 byte-values has no intrinsic meaning. What you need is an interpreting device outside which makes the sequence a program, a sound or an image. One 256-sequence may be a valid program on one processor, but will crash on another one. Would be an interesting question, how high (or better: low) the percentage of randomly generated 256-programs is that will not crash on a given processor. Like the halting problem generally undecidable, I reckon.
Actual machine languages are completely inappropriate for experiments like these just because of their extremely poor robustness: flip a single bit somewhere in a functioning code - and it will crash (ok, not in 100% of cases). I would propose that a starting point for any randomly generated programs should be the design of a new language, that has mainly one feature: robustness against mutations. :)
Change bits and bytes and it will still execute (maybe in endless loops, but that's unavoidable, I think).
Oh, that's like Core War then, right? :)
>take off sunglasses
Seamen and fishermen alike swear to have heard voices in the rising tide. Inhuman screams, some of them say.
User avatar
20thCenturyBoy
Baaaaa!
Baaaaa!
Posts: 1093
Joined: Fri Oct 01, 2004 8:16 am 0
Location: Perth, Australia

Post by 20thCenturyBoy »

can anyone point me in the right direction? which compiler to use? some x86 asm documentation. and basically, how do i get a mode13 screen up and how do i plot pixels on it?
Here's the assembler for hell.com, all 256 bytes of it. As you can see you can get into Mode 13h in two lines!

Code: Select all

1516:0100 B013          MOV     AL,13
1516:0102 CD10          INT     10
1516:0104 BF28D3        MOV     DI,D328
1516:0107 BAC803        MOV     DX,03C8
1516:010A 66            DB      66
1516:010B 33C0          XOR     AX,AX
1516:010D EE            OUT     DX,AL
1516:010E 42            INC     DX
1516:010F B4A0          MOV     AH,A0
1516:0111 B90004        MOV     CX,0400
1516:0114 50            PUSH    AX
1516:0115 66            DB      66
1516:0116 C1            DB      C1
1516:0117 C8            DB      C8
1516:0118 083C          OR      [SI],BH
1516:011A 3F            AAS
1516:011B 7205          JB      0122
1516:011D B03F          MOV     AL,3F
1516:011F 80C401        ADD     AH,01
1516:0122 F6C103        TEST    CL,03
1516:0125 7401          JZ      0128
1516:0127 EE            OUT     DX,AL
1516:0128 E2EB          LOOP    0115
1516:012A BBF0FF        MOV     BX,FFF0
1516:012D B120          MOV     CL,20
1516:012F 8BC3          MOV     AX,BX
1516:0131 F7E8          IMUL    AX
1516:0133 AB            STOSW
1516:0134 43            INC     BX
1516:0135 E2F8          LOOP    012F
1516:0137 07            POP     ES
1516:0138 33FF          XOR     DI,DI
1516:013A 80440F02      ADD     BYTE PTR [SI+0F],02
1516:013E C7440270FE    MOV     WORD PTR [SI+02],FE70
1516:0143 DF440E                FILD    WORD PTR [SI+0E]
1516:0146 DE7404                FIDIV   WORD PTR [SI+04]
1516:0149
1516:014B DE4C5D                FIMUL   WORD PTR [SI+5D]
1516:014E DF5C0A                FISTP   WORD PTR [SI+0A]
1516:0151 C70480FD      MOV     WORD PTR [SI],FD80
1516:0155 57            PUSH    DI
1516:0156 56            PUSH    SI
1516:0157 8B7C0E        MOV     DI,[SI+0E]
1516:015A 03FF          ADD     DI,DI
1516:015C BA0080        MOV     DX,8000
1516:015F 03FA          ADD     DI,DX
1516:0161 8B6C0A        MOV     BP,[SI+0A]
1516:0164 03D5          ADD     DX,BP
1516:0166 C1            DB      C1
1516:0167 FD            STD
1516:0168 0B0F          OR      CX,[BX]
1516:016A AF            SCASW
1516:016B 6C            DB      6C
1516:016C 02F6          ADD     DH,DH
1516:016E E6C1          OUT     C1,AL
1516:0170 E808F6        CALL    F77B
1516:0173 64            DB      64
1516:0174 06            PUSH    ES
1516:0175 50            PUSH    AX
1516:0176 B8FF01        MOV     AX,01FF
1516:0179 2AC6          SUB     AL,DH
1516:017B 8BDF          MOV     BX,DI
1516:017D 8BF2          MOV     SI,DX
1516:017F C1            DB      C1
1516:0180 FB            STI
1516:0181 0CC1          OR      AL,C1
1516:0183 FE0C          DEC     BYTE PTR [SI]
1516:0185 03DB          ADD     BX,BX
1516:0187 03F6          ADD     SI,SI
1516:0189 8B8F48D3      MOV     CX,[BX+D348]
1516:018D 8BDD          MOV     BX,BP
1516:018F 038C48D3      ADD     CX,[SI+D348]
1516:0193 C1            DB      C1
1516:0194 FB            STI
1516:0195 0C03          OR      AL,03
1516:0197 DB03                  FILD    DWORD PTR [BP+DI]
1516:0199 8F48D3        POP     [BX+SI-2D]
1516:019C 81C70002      ADD     DI,0200
1516:01A0 83F968        CMP     CX,+68
1516:01A3 7D0B          JGE     01B0
1516:01A5 03160201      ADD     DX,[0102]
1516:01A9 032E0001      ADD     BP,[0100]
1516:01AD 48            DEC     AX
1516:01AE 75CB          JNZ     017B
1516:01B0 C1            DB      C1
1516:01B1 E80259        CALL    5AB6
1516:01B4 02C5          ADD     AL,CH
1516:01B6 87CE          XCHG    CX,SI
1516:01B8 5E            POP     SI
1516:01B9 2B5402        SUB     DX,[SI+02]
1516:01BC D1F9          SAR     CX,1
1516:01BE C1            DB      C1
1516:01BF FA            CLI
1516:01C0 0C3B          OR      AL,3B
1516:01C2 CA7404        RETF    0474
1516:01C5 2C10          SUB     AL,10
1516:01C7 EB0D          JMP     01D6
1516:01C9 2B2C          SUB     BP,[SI]
1516:01CB D1FB          SAR     BX,1
1516:01CD C1            DB      C1
1516:01CE FD            STD
1516:01CF 0C3B          OR      AL,3B
1516:01D1 DD7406                FSAVE   [SI+06]
1516:01D4 2C08          SUB     AL,08
1516:01D6 7302          JNB     01DA
1516:01D8 33C0          XOR     AX,AX
1516:01DA 5F            POP     DI
1516:01DB AA            STOSB
1516:01DC 830404        ADD     WORD PTR [SI],+04
1516:01DF 813C8002      CMP     WORD PTR [SI],0280
1516:01E3 0F            DB      0F
1516:01E4 8C6EFF        MOV     [BP-01],CS
1516:01E7 83440204      ADD     WORD PTR [SI+02],+04
1516:01EB 817C029001    CMP     WORD PTR [SI+02],0190
1516:01F0 0F            DB      0F
1516:01F1 8C5DFF        MOV     [DI-01],DS
1516:01F4 E460          IN      AL,60
1516:01F6 48            DEC     AX
1516:01F7 0F            DB      0F
1516:01F8 853D          TEST    DI,[DI]
1516:01FA FFB003CD      PUSH    [BX+SI+CD03]
1516:01FE 10C3          ADC     BL,AL
Visual C++ comes with an assembler that can create .com files, or you can just type the codes into the "debug" program that you get with XP.
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Post by Dio »

Mr Sheen wrote:I was wondering that, if I was to write a program that generated every possible 256byte sequence...and then try and run it...would it too come up with those programs? I.E., do they exist in the universe already? What other programs exists in that 256byte space that I could "randomly" generate and execute. How long would a super computer take to generate every possible 256byte sequence.
There are about as many 32 byte programs as there are atoms in the universe (10 to the 77, the universe is around 10 to the 80 atoms IIRC).

There are 10 to the 616 256 byte programs. That's a lot.
User avatar
failrate
Baaaaaa!
Baaaaaa!
Posts: 2354
Joined: Sun May 23, 2004 6:54 am 0
Location: Sandy Eggo
Contact:

Post by failrate »

So, a practical function to discover them all would have to be only semi-random. Certain sequences could be invalidated right out the gate, innit?

This puts me in a mind of an old science fiction story I read about a team of programmers and engineers employed by a Tibetan cult to calculate the 99.999 names of God. They used iterative generation with certain rules (like a consonant-vowel pair would always be followed by another consonant or something like that) in order to invalidate certain results and minimize the generated set. Great story, wish I could remember the title, as I don't want to spoil the ending :twisted:

But let's say we start with a complete piece of valid code, like hell.com, and the generator is capable of running it in a shell, and detecting if it runs correctly or not (detect crashes, bad memory allocations, etc.)... you could probably program a neural net or evolutionary construct, innit?
User avatar
wossname
Baa!
Baa!
Posts: 52
Joined: Fri Oct 07, 2005 8:46 pm 0

Post by wossname »

Holy shit! That is amazing.

Further to the discussion of auto-generating bug free programs, it is possible if you use a Genetic Algorithm to evaluate each program.

This would be extremely easy to do since all a program is is a long string of binary...analogous to DNA strands.

All you have to do is randomly mutate a program's binary and then evaluate the next generation. Add new programs to the gene pool and breed them together (using weighted random functions).

For a program to be suitable for breeding, it has to at least compile without error. The hard part will be actually knowing how to recognise a really cool looking graphics app.

If we had a more simple design brief, for example reversing the commandline parameter %1 for instance then this can easily be judged and we'd probably be able to 'breed' a program to do this within a few hours.





An interesting aside to this discussion includes the evolution of hardware circuitry...http://www.cogs.susx.ac.uk/users/adrianth/ade.html
I give good code.
Post Reply