PDA

View Full Version : Make a mess



mike_g
03-24-2008, 01:21 PM
How about a little group project for some light entertainment? This project has no specific aim, and anyone can contribute by adding/changing whatever they like, as long as it meets the rules. To do so take the most recent version, add something to it, then post it back.

The rules are simple:
1) Each new revision must compile with g++, but may have bugs in it (deliberate or not).
2) Only standard libraries can be included.
3) New versions should describe roughly what was changed.

I'm sure that between the lot of us we can come up with something amazing. I attached something to start off with.

Elysia
03-24-2008, 01:29 PM
C or C++?

mike_g
03-24-2008, 01:32 PM
Code in whatever will work, although probably no ASM unless its going to on all PCs.

Yarin
03-24-2008, 01:41 PM
An update of your man struct, it really needed it:


struct DATE {
WORD year, month, day, hour, minute, second, millisecond;
};

typedef struct { // version 2
pman mother, father;
BOOL sex;
char *name;
double x, y;
DATE birth;
} man, *pman;

Elysia
03-24-2008, 01:43 PM
No, no, what you really need is:

man* people[100];
people[0] = MakeMan("Bob");
printf("Hello I am %s ", people[0]->name);
free(people[0]);
getchar();

brewbuck
03-24-2008, 01:43 PM
typedef struct { // version 2
pman mother, father;

mother is a pointer to a man?

Dave_Sinkula
03-24-2008, 01:44 PM
Removing the disgusting pointer typedef...

struct DATE {
WORD year, month, day, hour, minute, second, millisecond;
};

typedef struct { // version 2
pman mother, father;
BOOL sex;
char *name;
double x, y;
DATE birth;
} man;

Yarin
03-24-2008, 01:48 PM
>> mother is a pointer to a man?
yes, the man struct is just a human.

Yarin
03-24-2008, 01:55 PM
dave, if you get rid of code, you should add new stuff to take it's place.

another update:


... // code needs to be made for the memory & ai

struct DATE {
WORD year, month, day, hour, minute, second, millisecond;
};

class HUMAN { // version 3
// family
PHUMAN mother, father;
PHUMAN *child;
DWORD children;
// specifiers
BOOL sex;
char *name;
double x, y, z;
DATE birth;
// more
BRAIN mem;
};

typedef PHUMAN *HUMAN; // I like typedefs! >:(

Dave_Sinkula
03-24-2008, 01:58 PM
>dave, if you get rid of code, you should add new stuff to take it's place.
Naw. To quote Prelude (http://cboard.cprogramming.com/member.php?u=322): "My best code is written with the delete key."

Elysia
03-24-2008, 02:01 PM
I hate pointer typedefs/defines. They only make the code harder to read.
And gender should be an enum!
And no char*, only std::string!
What's missing is smart pointers, though.


struct DATE
{
WORD year;
WORD month;
WORD day;
WORD hour;
WORD minute;
WORD second;
WORD millisecond;
};

enum eGender
{
Female,
Male
};

struct HUMAN
{ // version 3
// family
HUMAN* mother;
HUMAN* father;
HUMAN* child;
DWORD children;
// specifiers
eGender gender;
std::string name;
double x, y, z;
DATE birth;
// more
BRAIN mem;
};

mike_g
03-24-2008, 02:06 PM
Yarin:
Small alterations can be left in comments, like dave's, and elysia's.

If you are going to change the structures, you should alter the rest of the code to facilitate this. For example, whats BRAIN? If you simply dump your structs in, it will mangle the prog. Not that theres much to get mangled yet, but maybe post something that will compile?

Elysia
03-24-2008, 02:08 PM
class BRAIN
{
public:
BRAIN(): bHasBrain(false) { }
bool bHasBrain;
};

struct DATE
{
WORD year;
WORD month;
WORD day;
WORD hour;
WORD minute;
WORD second;
WORD millisecond;
};

enum eGender
{
Female,
Male
};

struct HUMAN
{ // version 3
// family
HUMAN* mother;
HUMAN* father;
HUMAN* child;
DWORD children;
// specifiers
eGender gender;
std::string name;
double x, y, z;
DATE birth;
// more
BRAIN mem;
};

:D:D:D

whiteflags
03-24-2008, 02:11 PM
And here I was just going to do a stupid little die roll, and make "Bob" walk somewhere.

Yarin
03-24-2008, 02:14 PM
Much better. :D


class BRAIN
{
public:
BRAIN(): bHasBrain(false) { }
bool bHasBrain;
};

struct DATE
{
WORD year;
WORD month;
WORD day;
WORD hour;
WORD minute;
WORD second;
WORD millisecond;
};

enum gender
{
female,
male
};

struct HUMAN
{
// version 3
// family
HUMAN *mother;
HUMAN *father;
HUMAN **kid;
DWORD kids;
// specifiers
gender sex;
char *name;
double x, y, z;
DATE birth;
// more
BRAIN mem;
};

Code + tabs = unreadable hash of mashed tomato juice!

mike_g
03-24-2008, 02:16 PM
Well if you want to go for it citizen. So far the last valid submission was my original post :(

1) Each new revision must compile with g++, but may have bugs in it (deliberate or not).

Elysia
03-24-2008, 02:17 PM
Hmmm.

class BRAIN
{
public:
BRAIN(): bHasBrain(false) { }
bool bHasBrain;
};

struct DATE
{
WORD year;
WORD month;
WORD day;
WORD hour;
WORD minute;
WORD second;
WORD millisecond;
};

enum gender
{
female,
male
};

struct HUMAN
{
// version 3
// family
HUMAN* mother;
HUMAN* father;
std::vector<HUMAN*> children;
DWORD dwChildren;
// specifiers
gender sex;
std::string name;
double x, y, z;
DATE birth;
// more
BRAIN mem;
};
Let's stop making life so hard on us... When we have C++, let's use it! ;)
And I still prefer tabs. You stole my quote, and now you try to steal it again? :rolleyes:

mike_g
03-24-2008, 02:20 PM
Elysia: could you please put that in a file w/ relevant includes and stuff in a form that will compile and maybe do something? That would give the next person something to work with :)

Yarin
03-24-2008, 02:20 PM
>> And here I was just going to do a stupid little die roll, and make "Bob" walk somewhere.

Ah, great idea!



BOOL HUMAN::Rotate(double rads)
{
rot = rads;
return TRUE;
}

BOOL HUMAN::Walk(double distance)
{
x += cos(rot) * distance;
y += sin(rot) * distance;
z = GetHeightMap(NULL, x, y);
return TRUE;
}

whiteflags
03-24-2008, 02:27 PM
That's a horrible class. Each instance of HUMAN has a children vector, even if a particular human is only part of a family. Some humans don't have children so I'm not sure if that is a part of being human. Not to mention that we're using WORDS and DWORDS, which isn't very cross-platform, but mike wants it to work on g++.

Hmmm, with these problems, I think I liked Bob more.

Going somewhere with the class, Elysia?

Yarin: thanks for that. :p

Elysia
03-24-2008, 02:30 PM
Putting it into something compilable now.

Elysia
03-24-2008, 03:10 PM
Alright, here's the source, tested and everything.
Now feel free to continue building on it.

manav
03-25-2008, 12:34 AM
how about making them reproduce now! without any help from programmers!

Elysia
03-25-2008, 02:29 AM
If you want it, go ahead, code it ;)

zacs7
03-25-2008, 02:43 AM
If you want it, go ahead, code it ;)

Need a method man.sexytime(). Problem is, they won't be able to reproduce if they're both men :\ -- although they can still have 'sexytime'.

Dave_Sinkula
03-25-2008, 09:14 AM
Alright, here's the source, tested and everything.My build has a few issues with that.

start.cpp:1:20: stdafx.h: No such file or directory
start.cpp:13: error: use of enum `gender' without previous declaration
start.cpp:17: error: `gender' was not declared in this scope
start.cpp:18: error: `gender' was not declared in this scope
start.cpp:19: error: `gender' was not declared in this scope
start.cpp: In function `std::string GetChildType(gender)':
start.cpp:89: error: `std::string GetChildType(gender)' redeclared as different kind of symbol
start.cpp:17: error: previous declaration of `std::string GetChildType'
start.cpp:17: error: previous non-function declaration `std::string GetChildType'
start.cpp:89: error: conflicts with function declaration `std::string GetChildType(gender)'
start.cpp: In function `std::string GetHisHer(gender)':
start.cpp:100: error: `std::string GetHisHer(gender)' redeclared as different kind of symbol
start.cpp:18: error: previous declaration of `std::string GetHisHer'
start.cpp:18: error: previous non-function declaration `std::string GetHisHer'
start.cpp:100: error: conflicts with function declaration `std::string GetHisHer(gender)'
start.cpp: In function `std::string GetHeShe(gender)':
start.cpp:111: error: `std::string GetHeShe(gender)' redeclared as different kind of symbol
start.cpp:19: error: previous declaration of `std::string GetHeShe'
start.cpp:19: error: previous non-function declaration `std::string GetHeShe'
start.cpp:111: error: conflicts with function declaration `std::string GetHeShe(gender)'
start.cpp: In function `void DisplayChildren(const HUMAN&)':
start.cpp:148: error: no match for call to `(std::string) (gender&)'
start.cpp:148: error: no match for call to `(std::string) (gender&)'
*** Errors occurred during this build ***

Elysia
03-25-2008, 09:19 AM
How about this then?
Disabled precompiled headers.
Moved declarations and definitions to top, above the prototypes.

Dave_Sinkula
03-25-2008, 09:31 AM
That'll play. Danke.