Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411992 Posts in 69441 Topics- by 58486 Members - Latest Member: Fuimus

June 17, 2024, 02:15:39 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Malbolge
Pages: [1]
Print
Author Topic: Malbolge  (Read 2853 times)
Glaiel-Gamer
Guest
« on: January 05, 2009, 04:06:01 PM »

Anyone here ever use Malbolge? It looks pretty interesting and after reading through that article a few times I think I get how it works at least in theory.

Now actually doing something in it... that's another story.
Logged
Michelle Disraeli
Level 0
**


View Profile
« Reply #1 on: January 05, 2009, 04:32:25 PM »

Malbolge, not so much a programming language, but a programmer's game...
Where the code for just straight printing 99 bottle of beer is shorter than the version done with a loop o.O
Logged
Glaiel-Gamer
Guest
« Reply #2 on: January 05, 2009, 06:55:34 PM »

Actually I think it would be interesting to try and come up with a crazier programming language that's still manageable. If you look at the malbolge virtual machine, it's a really small c file that just parses the malbolge file you give to it, so it wouldn't be too hard to make an interpreter for a crazy language.
Logged
Michelle Disraeli
Level 0
**


View Profile
« Reply #3 on: January 05, 2009, 07:38:19 PM »

Interpreters for custom simple languages (like most esoteric ones) are quite simple, yes. I once threw a simple one together for the single instruction instruction set, it took me less than half an hour to build in BASH Tongue

Making something crazier than malbolge wouldn't be that hard. The person who seemingly did most of the english work on understanding malbolge gave some starting points for making it worse.

Whilst I love the weirdest of the esoteric langauges for the head breakage they cause, in practical terms I prefer the more artistic ones, like Shakespeare. It would be a much better challenge, in my opinion, to try and come up with a different and weird language that manages to really make source code into art (and not just the way perl aficionados do).

If I knew more of music theory, I would love to try and come up with one based on a musical score. I've not seen one done like that yet
Logged
Glaiel-Gamer
Guest
« Reply #4 on: January 05, 2009, 07:51:49 PM »

that could actually be really interesting, and luckily I know a lot about music theory.

Even though processing a midi file into an instruction set wouldn't require much theory, just assign a different instruction to each pitch, and let instructions be executed in parallel when there's a chord (could make it really weird like that)

Or go the piet route and have the change in pitch between notes represent the instruction to be executed

Or the size of the chord could be the instruction, allowing some musical arrangement of the chords

Rest = Nop
« Last Edit: January 05, 2009, 07:55:05 PM by Glaiel-Gamer » Logged
Javilop
Level 2
**



View Profile
« Reply #5 on: January 05, 2009, 08:01:29 PM »

 Shocked
Logged
J.G. Martins
Level 2
**


AKA anvilfolk


View Profile WWW
« Reply #6 on: January 05, 2009, 08:17:31 PM »

Make it a natively graphical language, like paintfuck and see the output of Für Elise. Must be so pretty. Also, must have flowers.
Logged

Gold is for the mistress -- silver for the maid --
Copper for the craftsman cunning at his trade.
"Good!" cried the Baron, sitting in his hall,
"But iron, cold iron, is the master of them all."
--- Rudyard Kipling
Michelle Disraeli
Level 0
**


View Profile
« Reply #7 on: January 05, 2009, 08:57:59 PM »

Even though processing a midi file into an instruction set wouldn't require much theory, just assign a different instruction to each pitch, and let instructions be executed in parallel when there's a chord (could make it really weird like that)

Or go the piet route and have the change in pitch between notes represent the instruction to be executed

Or the size of the chord could be the instruction, allowing some musical arrangement of the chords

Rest = Nop
That's a good start! Smiley

A really interesting touch I would love would be to have it inherently concurrent - each instrument's score is a different thread. Matters of locking could be avoided by simply assigning varying priority to differing sections of the orchestra/band (which ok, makes it less concurrent, but simple is good Tongue)

There are two different types of symbol to consider - opcodes themselves, and the data to go with them. There tends to only be a few opcodes, but in a RISC system they would repeat regularly unless means were found to allow them to each differ. Data typically needs to vary over a large range.

As such, I think it would be better to consider groups of notes, rather than individual notes.

From my work with the single instruction instruction set, I know that a registerless VM can work quite well, and means you have fewer opcode conditions to consider. I would probably consider using such a setup, and it feels appropriate for the problem - dancing along the memory. A Von Neumann architecture would also be a must, self-modifying music would amuse me Tongue

I wish I was more musically inclined - I feel this problem would be better addressed by working with the art first, and then fudging the figures used to ensure that whatever is written in the notes could sound good. What we need are repeatable structures of notes that can vary in their internal make-up (for the opcodes), and a sensible representation of literals that will also result in good sounds (this could also be based at least somewhat on patterns, rather that required positions).

If we can get the music figured out, I would be interested in throwing together a VM for this, actually Smiley I can certainly do the core VM easily enough, and perhaps musical output and graphics. Not being a musician, getting live midi programming to work would be difficult, but tempting in the long run.
Logged
Glaiel-Gamer
Guest
« Reply #8 on: January 05, 2009, 09:36:29 PM »

Well out of the nature of a musical chord, you could essentially use the notes themselves as a form of binary for adding data to an opcode and use chords themselves as an opcode, again with each music track being its own thread.

Alternatively, it could be made so that the volume of a note (which is usually one byte if I'm not mistaken) is the data passed to the code. If a typical opcode is 3 notes, then we can pass 24-bit values to each instruction (i'm gonna call them functions from here on out cause it's easier). The problem here is that, unless you are dealing with large numbers, most of the music would come out silent or very very quiet, so some sort of normalization would be needed here.

There's a number of chords which you can use for an opcode here, which can be any combination of major and minor 3rds, plus some 4ths and 5ths and even other odd intervals if need be, since those will all sound OK together if you are working in the same key.

But if you made the instruction set be simple, like

- Load from Memory
- Place in Memory
- Add/Subtract
- Jump
- Display Ascii
- Get Input Character
- NOP
- some conditional jumps
- set "program memory"

all the while it executes, it's playing the music (so it might be only be working at 2 or 4 hz, that's fine for these purposes)

It would be really neat to have the music self-replicating though. Dynamically generated music, written by the music itself. That one hasn't been done before, I don't think.
Logged
Glaiel-Gamer
Guest
« Reply #9 on: January 05, 2009, 09:39:15 PM »

If we can get the music figured out, I would be interested in throwing together a VM for this, actually Smiley I can certainly do the core VM easily enough, and perhaps musical output and graphics. Not being a musician, getting live midi programming to work would be difficult, but tempting in the long run.

Ya I think i could manage a VM for this pretty easily too, only thing I don't know how to do in c++ is output sound. If I did it in flash however....
Logged
Michelle Disraeli
Level 0
**


View Profile
« Reply #10 on: January 06, 2009, 08:50:58 AM »

I wouldn't use volume. That ties you to recorded music, and I prefer the idea of being able to distribute programs as scores. That would also allow your program to be performed, and by not specifying volume, you allow more artistic interpretation.

My current thoughts are to use groups of eight notes as the word size (CS term, rather than MS programming term), then simply using a fixed instruction/data size of 1 word, making a complete opcode (instruction + data) 3 words long. Instructions that need less data words would simply ignore the extra words. This keeps it simple to interpret, allows fun tricks (like reusing sections of code in different ways), and (importantly) offers the programmer/musician space to be artful.

In implementing a VM, I have came to the conclusion that registers are best avoided, and instead to work with a memory model alone. I believe this is how the Java VM does it (but it has been a while since I read the specification), using only a program counter and some flags.

In my experience, rather than using the idea of displays, a more generalised streams approach actually offers a lot more flexibility. You simply bind different input or output devices to the stream number/address (you could make these memory mapped, but that means you have to consider two different types of memory location, and from experience this quickly becomes a pain). This would even allow extremely strange things, like binding a stream to write to real memory, and another to then interpret words sent to it as API function calls with the data in the previous stream being used. Using this system also allows different streams to be set up for ascii output, and musical output.

To go extremely technical, a very clever thing to do would be to have values both being valid computational numbers, and being valid notes. By storing them in this fashion, you become able to process music as well as numbers, with the conversion being automatically being taken care of. The important thing here is to ensure that the same basic properties of working with numbers also applies to working with the music:

  • When adding two numeric values, the sum is the same as when adding two notes, and vice versa
  • Subtraction of notes should reverse addition of notes
  • ...Similarly for multiply and divide
  • ...And left shift and right shift
  • If many musical representations of the same number exist, all operations should map according to that note set, hence maintaining all axioms properly.
This would be fairly simple to do using a C++ class for representing the data. Sound output can be easily cheated by using SDL_Mixer or somesuch Tongue
Logged
nihilocrat
Level 10
*****


Full of stars.


View Profile WWW
« Reply #11 on: January 06, 2009, 01:10:27 PM »

Alternatively, it could be made so that the velocity of a note (which is usually one byte if I'm not mistaken)

Fixed.
Logged

Glaiel-Gamer
Guest
« Reply #12 on: January 06, 2009, 06:08:50 PM »

Alternatively, it could be made so that the velocity of a note (which is usually one byte if I'm not mistaken)

Fixed.

picky picky, I just know music on a practical level, not a digital level
Logged
increpare
Guest
« Reply #13 on: January 06, 2009, 06:29:54 PM »

I wouldn't use volume. That ties you to recorded music, and I prefer the idea of being able to distribute programs as scores. That would also allow your program to be performed, and by not specifying volume, you allow more artistic interpretation.
Most scores have dynamics...and are for the most part the better off for it...
Logged
J.G. Martins
Level 2
**


AKA anvilfolk


View Profile WWW
« Reply #14 on: January 06, 2009, 06:32:23 PM »

Ok, I think I got lost somewhere along this thread.

Are you guys planning on creating code from music, or music from code?
Logged

Gold is for the mistress -- silver for the maid --
Copper for the craftsman cunning at his trade.
"Good!" cried the Baron, sitting in his hall,
"But iron, cold iron, is the master of them all."
--- Rudyard Kipling
Glaiel-Gamer
Guest
« Reply #15 on: January 06, 2009, 07:03:15 PM »

BOTH!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic