Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2001:
[Freeciv-Dev] Re: Communications Protocol
Home

[Freeciv-Dev] Re: Communications Protocol

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Communications Protocol
From: Vasco Alexandre Da Silva Costa <vasc@xxxxxxxxxxxxxx>
Date: Sun, 15 Jul 2001 01:24:37 +0100 (WET DST)

On Sun, 15 Jul 2001, Pete Sergeant wrote:

> Hi there,
> 
> I want to write a Perl module that can act as a client to a civserver, to
> allow me, and anybody else who wants to, AI clients, using Neural Nets.
> 
> My stumbling block is the communication between the server and client. I had
> naively assumed it would be plaintext, but, of course, it isn't. My C is
> weak (as is my Java, because freeciv-java implements it too), and I really
> can't grok how it works from the source.
> 
> I was wondering if anybody would explain to me how the packets are
> constructed, and perhaps write a small piece of documentation on it, as I'm
> sure others would find it useful.

The packets are basically serialized structs. You can find the relevant
code at common/packets.h and common/packets.c.
Sometimes we serialize some fields in some special way to pack the data
more tightly. It would be easier to make the network code using something
like Sun RPC or Java but this is an easily portable C program so we have
to do this kind of stuff by hand ourselves. Of course this gives more room
for optimization.

Every packet follows this format:

<uint16:packet length><uint8: packet type><data bytes>...

Integers are sent in so called network byte order or big endian.

The per struct serialization functions are called receive_packet_*().


About AI... I don't think neural networks are the most suitable candidates
for the kind of problems presented by a game like freeciv. In freeciv the
rules, even if more complex than in some games, are explicit and
inflexible. Neural networks are good for perceiving patterns in the middle
of noise. I would use a mix of several other AI technologies like A*
search for pathfinding, influence maps for status assessment (which player
controls what zone, what is dangerous terrain and what is not etc) and
some kind of rules based system for taking high level decisions using
predefined tactics that are chosen according to the situation. 

Of course please prove me that i am wrong :-)

Good luck,

---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa



[Prev in Thread] Current Thread [Next in Thread]