Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Game for programmers: Pseudocode chaos  (Read 1687 times)

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Game for programmers: Pseudocode chaos
« on: November 28, 2009, 01:20:17 pm »

Okay, there is how this works:

You must post legal C code, in such a way that if I were to stick it all in one file, with appropriate function prototypes so that order doesn't matter, the only errors it gets is linker errors for undefined functions. What that means, is use legal C syntax, and throw in descriptively-named functions wherever you don't feel like writing the details.

In theory, what we will end up with, once all of the placeholder functions are written, is the most unexpected mass of feature-creep that is still barely able to compile.

Example: I define
Code: [Select]
int main(int argc,char *argv[])
{
    doStartup(argc,argv);
    while(keepRunning())
    {
        loopCode();
    }
    doEndStuff();
}
Then someone else starts adding to it, with
Code: [Select]
void loopCode()
{
    log_text("Ohai\n");
    calculate_physics(&player);
    create_enemies();
    do_input_stuff();
    draw_it_all();
}

Then as paeople go along, the end result is a crazy collection of diffrent styles, intentions and other stuff that makes countless memeory leaks, the occasional core dump, and a great example of what NOT to do.

Finally, with common consent, earlier code may be edited for any reason.

Okay, lets start.

We must decide between win32, console, or other, as it will greatly impact the potential features.

Only limit is that it must be commnly available C, and as a bare minimum, compiled on windows with MinGW and less than 10 MB of external library downloads(If everybody agrees, any of these limits may be negated, or new ones added).
Logged
Eh?
Eh!

Armok

  • Bay Watcher
  • God of Blood
    • View Profile
Re: Game for programmers: Pseudocode chaos
« Reply #1 on: November 28, 2009, 03:48:16 pm »

Damn, i want to play but I don't know c... Why couldn't this be python, or at least c++? I'll try some c++ code and hope it forts anywyas. ... I just realized it was so long since I used it I've forgoten 90% of my c++ stuff to... This probably isn't legal code, but whatever.

Code: [Select]
pointer doStartup(float argc, string argv)
{
    World = fillPlace(GenEmptyPlace(), "air");
    addVoxelPlanet(World*, 10, 56.0);
    erode(World);
     erode(World);
     erode(World);
     erode(World);
     erode(World);
     erode(World);
    AddCreture("player", World*, "auto");
      AddCreture("enemy", World*, "auto");
      AddCreture("enemy", World*, "auto");
      AddCreture("enemy", World*, "auto");
     run=True
    ClearInput();
}
Logged
So says Armok, God of blood.
Sszsszssoo...
Sszsszssaaayysss...
III...

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Game for programmers: Pseudocode chaos
« Reply #2 on: November 28, 2009, 03:59:12 pm »

What, building off the example code?

Code: [Select]
void doStartup(int argc,string *argv[])
{
    World = fillPlace(GenEmptyPlace(), "air");
    addVoxelPlanet(World*, 10, 56.0);
    erode(World);
    erode(World);
    erode(World);
    erode(World);
    erode(World);
    erode(World);
    AddCreture("player", World*, "auto");
    AddCreture("enemy", World*, "auto");
    AddCreture("enemy", World*, "auto");
    AddCreture("enemy", World*, "auto");
    run=True
    ClearInput();
}

Somewhat fixed: consistant indentation and function call. It doesn't return anything, so the type should be void, but if you wanted it to return a pointer of type aaa, you would use aaa* {function name}

So, the following needs to be defined:
Global vars:
{type: likely a struct} {*? probably at least two levels of pointer indirection} World
{type: boolean, if C has one, otherwise a substitute} run
Functions:
void AddCreture(char*,{same type as World, minus one level of indirection},char*)
void erode({same type as World})
void ClearInput()
addVoxelPlanet({same type as World, minus one level of indirection},{some type of number},{some variation on float,probably})
void doEndStuff()
void loopCode()
{some sort of true/false or convertable value like int, etc} keepRunning()


If we are building off of the example, I will declare that the example loopCode should be disregarded
Logged
Eh?
Eh!

RAM

  • Bay Watcher
    • View Profile
Re: Game for programmers: Pseudocode chaos
« Reply #3 on: November 28, 2009, 04:54:29 pm »

C isn't my language and programming isn't my skill, but this sounds interesting so I will post something to lurk.

Code: [Select]

SAD=1
STAIRS_UP=1
H_DIRECTIONS=8

boolean Find_Path(longint Subject,shortint Distance,int Target,(some sort of array or similar) Actions)
(comment) Finds the shortest path from the Subject creature to Target object within Distance moves and returns it as a series of Actions. Returns false if no path is found, true otherwise.

void Creature_Acts_Emotional(longint Subject, int Emotion)
(comment) Causes a creature to act according to an emotion.
??? Moves
boolean Successfully_Moved
{
if Emotion == SAD then
{
While Find_Path(Subject, 20, STAIRS_UP, Moves) and Successfully_Moved
Successfully_Moved=Move_Creature(Subject, Moves);
Moves=NO_ACTIONS
for 1..20 Add_Action(Moves,Random(H_DIRECTIONS);
Successfully_Moved=Move_Creature(Subject, Moves);
}
}
Logged
Vote (1) for the Urist scale!
I shall be eternally happy. I shall be able to construct elf hunting giant mecha. Which can pour magma.
Urist has been forced to use a friend as fertilizer lately.
Read the First Post!

eerr

  • Bay Watcher
    • View Profile
Re: Game for programmers: Pseudocode chaos
« Reply #4 on: November 28, 2009, 10:40:52 pm »

Someone badly needs to define the world, the player, the creatures, and the items!

I know what I would make for the player and items, but with no world, its a moot point.
Logged