Skip to main content
gamedev.net
🔒 Locked

Program Making Program =P

Started by caldiar Aug 24, 2006 at 11:11 AM 3 replies 700+ views
Original Post
caldiar
caldiar
I'm not actually interested in trying this out at the moment. The idea just happened to pop in my head while I was taking a shower last night. For whatever reason input/output code popped in my head and I suddenly thought, would it be possible to make a program that's simple a menu giving certain options and, based on the options chosen, spits out code into a .cpp file then has a compiler compile the resulting file into something useable? Psuedo-Code Example:

#all of the usual headers/includes and whatnot

menu_create(whatever){
    if(dependency is running){
        create_menu_list();
    }
    else{ 
        start_dependencies();
    }
}

menu_run(){
    if(menu_created){
        check_for_input;
    }
    else{
        menu_create();
    }
    //run cases for menu options
    switch(variable){
        case option1: 
            if(code dependecies met){
                output_text("output_file.cpp", "the code to write to output_file.cpp.  Example, 
if(world_geometry_built){ 
    start_lighting_process();
else{
    build_world_geometry();
}")
            else{
                create_option1_dependecies();
            }
            break;
        case option2:
            //etc........
        }
    }

main(){
    all_of_the_usual_system_stuff;
    menu_run();
    onQuit(); //stop the menu and remove from memory then kill the application. You know, the usual stuff
    }


Naturally this would be usefull to the people who have no idea how to program but have an idea they want to see come to life. All they'd have to do is run this program, fill out the appropiate options in the menu to build the game engine, fill out the submenu for adding in game content, then let the program compile and execute. This would also be good for somebody that wants to build a "custom" engine and doesn't want to put time in to building one from scratch. They could use this to build a template and then go in to tweak settings to their needs. I'm interested in knowing if anybody/company has gone and done something like this yet and if not, why?
ordered_disorder
ordered_disorder
This is pretty much the Idea behind VB, GameMaker, UML and a whole lot more. You drag and drop components, check a few options here, and check a few options there, and DING!, you have your code. You can tweak the code until your hearts desire or leave it in default form.
Doggan
Doggan
Self-generating code and self-modifying code is a fairly active area of research, particularly relating to artificial intelligence, and it's nothing new. Just look at LISP - which was created in the 50's - and it's eval statement. That is one of the large source of LISPs power and appeal to the AI community - the ability to produce new behaviors at run time and execute them in a single statement.

Your code is an example of a much much more straightforward concept of 'self-generating code'. In fact, it's not even self-generating code, since the actual code written to the cpp file was originally written by a human and stored within the 'generating' program.

If you have ever used Visual Studio's form editor, you will see similar behavior. Creating a button and then assigning callbacks and properties to it is all done through a GUI. But this is actually generating source code that is placed in your file. Care must be taken with systems like these, though. There is a LOT of fugly .NET code out there written by code-monkeys who don't bother to make meaningful variable names, or clean up unused variables and functions generated by the VS form editor.
yadango
yadango
so does Macromedia/Adobe Authorware. wish i had some advice for ya, i've been thinking about making a program like Authorware (but more affordable and accessible to more than just academics who can just throw away their grant money)...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.