The Chaos Project (working title)

Posted by Powerful Kyurem on Dec. 28, 2013, 1:13 a.m.

So, for the past few days, I have been attempting to literally create chaos in Game Maker.

So what is chaos exactly?

Well, it is a program with one object that randomizes a string and then, if it is valid, executes it.

Sounds simple right? Why do it?

Well, it isn't simple, first of all. There are over 1,000,000 possible permutations, and over half of them are invalid!

So why do this? Well, because it is interesting. What would happen in a chaotic state. There is essentially an equal chance for anything to occur (assuming GM can do it). What would happen? It might make an awesome video game level, AI, weird visual effects, nothing, or (if you ran it in GM Pro that allows external file editing) a virus. The results are limitless.

Currently the 'debugger' uses me to check it. I simply click yes or no on whether it is valid, and it records my answer (granted it resets every time I run it).

I have recently considered having two types of random generated code to limit wasteful combinations:

1. Creating another object.

2. Setting another object's event code to a ligit GML String.

This would limit combinations that do nothing, and would probably increase the amount of chaos in the simulation.

Comments

firestormx 10 years, 11 months ago

A few thoughts (and I don't mean to sound condescending):

1) "chaos" is limited only to what GM can actually do. My recommendation is to do something like create an array with each available function name in GM, and randomly pull from that array. Your debugger will just ignore any code that isn't a GM function anyway, so why not feed your program valid function names to begin with? The results will be the same - except far more efficient.

2) Are these strings just to create random function names, or does it need to build an entire function call with its syntax, complete with arguments, data types, etc? eg requiring the function name to end in "(", and then generate the appropriate number of arguments (with the correct data types/enclosures), and end with a ");", will significantly decrease the amount of valid output by your random generation.

Edit: I forgot GM doesn't require ";"

If you want something to viably execute functions at random, I'd recommend building an array (or DS, or whatever you want to do) of what arguments each function accepts, with their data type.

Then, when you bring up your random function, you loop through the arguments that are available, and generate random data that is appropriate for the arguments.

"Building" your string this way, will ensure proper syntax, number of arguments, and correct input.

3) Unless this starts generating extra logic (eg loops, if statements, etc), it's not going to be very useful.

4) It's quite difficult to fry your PC, unless you're making your own machine code. And even then, hardware and OSes do a lot to prevent machine code from harming your hardware, or even your OS.

5) As was mentioned, you could drop this into a try/catch, to easily catch nonexecutable code. I assume that works in GM.

6) I'm not sure that adding more objects would increase the output at all. The object would execute the code once per step (unless you're putting it within a loop), so increasing the steps per second (or putting it in a loop, and upping the loop iteration per step) would speed things up. When it gets to the point where it's stepping/iterating faster than your processor can process the request, then adding more objects won't make your processor go any faster.

In other words, you can get the most out of your processor with a single object, without needing multiple objects.

Edit: goddamnit, me too.

LAR Games 10 years, 11 months ago
firestormx 10 years, 11 months ago

I'm also curious about this:

Quote:
Currently the 'debugger' uses me to check it. I simply click yes or no on whether it is valid, and it records my answer (granted it resets every time I run it).
Have you come across a string where you have been able to click "yes" yet? :p

Toast 10 years, 11 months ago

Quote:
44 digits isn't that bad
No, 64 is the worst.

User was banned for this post

Powerful Kyurem 10 years, 11 months ago

FirestormX:

2. It is to generate any piece of GML, not just functions, so making a string builder would get very impractical.

4. I might be misunderstanding, but if GM compiled 'fjrjrvht' and ran it, it would probably do something bad.

No, there has been no valid output yet beyond 3 characters.

firestormx 10 years, 11 months ago

Quote:
4. I might be misunderstanding, but if GM compiled 'fjrjrvht' and ran it, it would probably do something bad.

It depends what GM would compile 'fjrjrvht' to, I suppose.

Quietus 10 years, 11 months ago

this sounds interesting actually; generating an entire game, from level design to AI to physics to graphics, maybe even music, based off a code of letters and numbers.

*reads comments* okay i have no idea what this is about, you lost me at machine learning. i mean that makes sense, but tricky if the AI and levels are randomly generated. i like the genetic algorithm idea in general though.

Powerful Kyurem 10 years, 11 months ago

Hel: I wouldn't pay too close attention to all the comments. A lot of the people started going into a random discussion of programs making programs…

Astryl 10 years, 11 months ago

Quote:

Hel: I wouldn't pay too close attention to all the comments. A lot of the people started going into a random discussion of programs making programs…

Which is basically what you're "doing", just in a very inefficient way. So people mentioned a few alternate methods.

Quote:
4. I might be misunderstanding, but if GM compiled 'fjrjrvht' and ran it, it would probably do something bad.
Firstly, GM doesn't 'compile' anything. Secondly, if you have errors disabled, GM won't do anything with a random string like this (It still gets the error message internally but doesn't alert the user).

So nothing bad, but nothing useful either.

EDIT: And a quicker way to get results in GM would be to have an array of strings that already contain valid calls, then generate random numbers within the bounds of that array and execute.

Would still be completely useless, but at least it would appear to do a few things. Parameters can be randomized on call for extra effectiveness.

Iasper 10 years, 11 months ago

No offense here INH but next time you do something like this you might want to do some research before you post a blog so the comments aren't filled with corrections and suggestions.