hachi from the block (hachibambatar) wrote in multitic,
hachi from the block

  • Mood:
  • Music:


alright, so my plan is to write a c++ backend for a multitic system on the server... here's the deal though, i've /never/ written network or gui code before... if i have to, i will, but please don't make me, that or point me to a nice sockets library...

the storage for a game is as follows, much as the coordinates would be written as a list of numbers between zero and two, the game is stored as a list of moves.

here's the class, things will be simpler that way, hopefully...

class Game {

public :

// Constructors, destructors and the like...
Game(); // default constructor
Game( string name, int ndimensions, int nplayers, int gametype ); // this should make some sense, gametype is a flag variable...
~Game(); // the destructor is going to do some database stuff if the gametype happens to be rated...

// Setup
void addplayer(int playerid); // i don't quite know what the implementation of playerids will be, except that they will be 32 bit ints...
void removeplayer(int playerid); // not everything needs a comment...

// Gameplay related
void move(char *pos); // this function is nothing more than a malloc and a memcpy with some error checking so that people don't make illegal moves...
void undo(); // guess what this does...
int iswon(); // is the game won?
int iscatsgame(); // is it a cats game?

// File related
int save(string filename) const; // save the game to a file on the server
int load(string filename); // load up a game from a file on the server

private :

int gametype;
int ndimensions;
int nplayers;
int *playerids;
int nmoves;
int counter = 0;
char *history;


post questions about this, anytime, or if you have a better model for the program or anything to say, do go ahead and say so... cvs, bah...
  • Post a new comment


    default userpic
Why not do it in perl? Crossplatform, pretty, and a language I need practice in.

Actually, I'm just suggesting Perl because (A) I'm better with it than C and friends, and (B) I despise CPP. C all the way.

Anyway, any particular reason you're choosing the bloat known as C++? You're even suggesting C style approaches to building functions (namely, malloc and memcpy). I suppose setting down a protocol for client/server communication would be more important to set up, as then, anyone could start working on a piece in anything. Im particularly interested in porting this to the PS2 and playing with some nifty rendering techniques (for which Id need it in C).

And Im less interested in the game class than the board class. The latter would influence a lot of where bloat could be cut in game, and what functions would be necessary.

i shall attempt an itemized response.

as for perl, it may be crossplatform, but pretty, it is not... also, the server has no need for being crossplatform, except to the extent of being able to run on all *nix systems, which are not particularly different at the level i plan to write this thing on...

as for your reasons for perl :
a) well, i'm very good at c, and terrible at perl
b) cpp is not very good, i'll admit...

frankly, i wrote it down in cpp because cpp class declarations are really excellent for putting down the structure of a program.

in my mind, boards should never be kept on the server and instead done at client-side... my vision is as follows, the server stores what is merely a list of moves, requiring minimal storage and ridiculously easy to search. (well, assuming we keep dimension below 6 or so)... client sends a move to the server, and the server responds with whether the move was valid and updates state, then sends the new move to everyone... server sends messages to the next player, setting things up so that it is alright to move... (plus error checking, pinging, timeouts, etc...) client-side storage depends on the client, which frankly, i don't plan to write, or if i do, it'll be a reminiscent of classic gnugo (and not the one that uses curses either)...

note that by doing this, one could do everything with datagrams... it could even be done with http, though that seems on the surface rather silly to me...

i will post the format of a move soon along with the messages that are to be sent accompanying them.

you wouldn't need it in anything if it is merely a protocol and a server, and in fact, w