Re: [Freeciv-Dev] Freeciv AI development

2012-09-18 Thread Matthias F. Brandstetter
Thanks, I will check that out a bit more in detail and get back to you then!

Regards


On 18 September 2012 01:49, Marko Lindqvist cazf...@gmail.com wrote:
 On 16 September 2012 15:52, Matthias F. Brandstetter m...@mabra.me wrote:
 Hi Freeciv Team!

 I am a PhD candidate at De Montfort University in UK, working on
 Computational Intelligence for Computer Games. For my current studies
 I am thinking of using Freeciv as test bed for my research on AI in
 games.

 On your web site I have seen that you are currently re-writing the AI
 code for v2.4.

  Actually, we've for most part ceased feature development for 2.4 last
 November when we branched stable branch to make 2.4 releases from once
 it gets stable enough. That AI reorganization was finished before
 that, though, and in since then there has been only a litlle bit of
 development on this field on trnk (from which next branch will be 2.5)

  That was not so much rewriting the AI code itself than reorganizing
 how it gets called. AI code used to be mangled to all server code, now
 things are more modular, AI code being separate from the other server
 code. It was done in a way that completely new AI implementations can
 be introduced as (loadable) modules - distinct players can use
 distinct AI implementations. Server calls AI callback functions at
 defined situations. Those callback functions for AI module to
 implement are listed in common/ai.h. In addition to those callback
 functions module needs to define just two functions, one to initialize
 it and second to return its capability string for checking
 compatibility between the server code and the module while loading the
 module.

 Is there any document describing the big picture for
 custom AI's? I have skipped through the latest source code a bit, seen
 the AI stub and ai.* files in the common dir, but I am not sure
 about each of these functions in detail,m when they are called, etc.

  I'm afraid the documentation is still quite much lacking - so far
 I've only added comments to common/ai.h about when each callback gets
 called.

  As AI runs just as part of server binary, it has access to all the
 data, freedom to modify it any way it wants, and to call any server
 functions. This means that AI module can cheat as much as author dares
 to make it to cheat. It also gives AI author responsibility not to
 mess game state.

 Also, I am new to Freeciv dev in general, have not worked on the code
 so far, only played the game in the past. What would be the best way
 of debugging my own development? When writing a new AI for Freeciv, I
 of course want to see how it works  bit for bit, so a debugging feature
 would be very handy!

  There's no single catch-it-all feature for debugging. Depending on
 what exactly I've wanted to know, I've combined several techniques. In
 most cases you want to run autogames (games with no human players)
 with predefined random seeds for reproducibility. You can run them in
 debugger, collect logs (get familiar with logging macros in
 utility/log.h) and compare results between original and modified AI,
 creating starting situations in editor.

  That's the most general level view, feel free to ask more detailed
 questions once you get yourself familarized with the code.


  - ML



-- 
Matthias F. Brandstetter
m...@mabra.me

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] Freeciv AI development

2012-09-17 Thread Gilles J. Seguin
On Sun, 2012-09-16 at 14:52 +0200, Matthias F. Brandstetter wrote:
 Hi Freeciv Team!
 
 I am a PhD candidate at De Montfort University in UK, working on
 Computational Intelligence for Computer Games. 

you got the right name, AFAIK the (meta-)heuristic date back
like 15 years, where unit like fighter and stealth were not implemented.
In a time where connection was made with 14.4 kbps.

The game is design such that the lowest latency player win
(at least in combat). And receive commands can frooze the gui.
If you do not understand, then search simulation time
and increase the thing to like one seconde, and send 50 units,
everything will break loose. 

 For my current studies
 I am thinking of using Freeciv as test bed for my research on AI in
 games.

send me your progress.
Even more the library and scheme you intend to used.
Obviously, the CI will need to be put in a thread, and report when fast
enough.
In warciv, we used a custom island, to give same chance to every
players. the island is copy to to fit in the map.

designing fair map is also a challenge, when not using identical island.
Example, without using sea.  you should see the problematic, and how
computer intensive it is.

http://www.mapeditor.org/ can be some help for making map.
i find the isometric of no used for playing or analyzing strategy, you
may differ.

 On your web site I have seen that you are currently re-writing the AI
 code for v2.4.

i do not their intention/design, i am from warciv version.

  Is there any document describing the big picture for
 custom AI's? I have skipped through the latest source code a bit, seen
 the AI stub and ai.* files in the common dir, but I am not sure
 about each of these functions in detail,m when they are called, etc.

i can not help there. Part of the AI is also CM(city Management).

 Also, I am new to Freeciv dev in general, have not worked on the code
 so far, only played the game in the past.

  What would be the best way
 of debugging my own development? When writing a new AI for Freeciv, I
 of course want to see how it works bit for bit, so a debugging feature
 would be very handy!

recording/replaying would be very useful
- for testing
- for debugging

Since CI/AI is a client thing, it means gui(graphic user interface) is
in the way.
The easiest thing for debugging is to used two computers.
That is, you do not want input to mess up the gui event loop.

For the client, use gdb-server
==
you need a command like with IP of PC running kgdb for example
# gdbserver 192.168.0.3: 7000 client/civclient

which is added for me to a shell script, that is civ-gdbserver file
exec gdbserver 192.168.0.3:7000 $EXE ${1+$@}
where 7000 is the port that need to be open(if firewall), to connect
  to gdbserver
you will have message like
process prog created: pid = 1545
Listenning on port 7000

for the host, the one running graphic debugger like ddd kdbg

or gdb utility in cli(command line input)
# ddd
 file client/civclient   # need application to debug
in gdb window   we need to give command to connect to gdbserver, that is
 target remote 192.168.0.2:7000   #in gdb window, IP of PC wher playing

again i am using a shell script civ-kdbg file for starting
exec kdbg $EXE ${1+$@}
where macro EXE is from a line like
  [ -x $BUILDDIR/civclient ]  EXE=$BUILDDIR/civclient

graphic debugger will need another thing, --display=192.168.0.1

for debugging the application more easely, sockets should be put in a thread
or server will disconnect
...

why the the script and the BUILDDIR macro ?
because developper usely used build directory for different compiler options
make CFLAGS=-g -O0 -Wall -DNDEBUG

from source, you should see client and server directory
$ mkdir BUILD
$ cd BUILD
$ ../configure 21 | tee configure-july17.log
$ make CFLAGS=-g -O0 -Wall -DNDEBUG 21 | tee make-july17.log


the application is based on common/packets.def
those are the commands sent between server/client
server - acknowledge valid modifications
   - send modifications to authorized client
client - send wanted modifications
   - received valid modification
   - and make walt disney display of what is going on, that is gui part

it is not difficult to see other design
allieds are connecting to one head quarter
head quarter ask refere to validate changes(anticheating)
refere let other head quarters known about thing that they are allow to view.

simulation should/could be done without the gui(display).

AFAIK nobody has done memory management,
all memory allocation are OS call.



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] Freeciv AI development

2012-09-17 Thread Marko Lindqvist
On 17 September 2012 10:18, Gilles J. Seguin se...@videotron.ca wrote:

 Since CI/AI is a client thing,

 Please start making your homework, or stop making yur statements in
such an assertative tone. Your emails contain significant amount of
false information said in a way that may makes some people to believe
that you know somethign about what you are talking about.
 AI is completely server side thing. Most of the time I run AI
testgames without ever launhing client.


 - ML

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] Freeciv AI development

2012-09-17 Thread Gilles J. Seguin
On Mon, 2012-09-17 at 03:18 -0400, Gilles J. Seguin wrote:
 On Sun, 2012-09-16 at 14:52 +0200, Matthias F. Brandstetter wrote:
  Hi Freeciv Team!
  
  I am a PhD candidate at De Montfort University in UK, working on
  Computational Intelligence for Computer Games. 
 
 you got the right name, AFAIK the (meta-)heuristic date back
 like 15 years, where unit like fighter and stealth were not implemented.
 In a time where connection was made with 14.4 kbps.
 
 The game is design such that the lowest latency player win
 (at least in combat). And receive commands can frooze the gui.
 If you do not understand, then search simulation time
 and increase the thing to like one seconde, and send 50 units,
 everything will break loose. 
 
  For my current studies
  I am thinking of using Freeciv as test bed for my research on AI in
  games.
 
 send me your progress.
 Even more the library and scheme you intend to used.
 Obviously, the CI will need to be put in a thread, and report when fast
 enough.
 In warciv, we used a custom island, to give same chance to every
 players. the island is copy to to fit in the map.
 
 designing fair map is also a challenge, when not using identical island.
 Example, without using sea.  you should see the problematic, and how
 computer intensive it is.
 
 http://www.mapeditor.org/ can be some help for making map.
 i find the isometric of no used for playing or analyzing strategy, you
 may differ.
 
  On your web site I have seen that you are currently re-writing the AI
  code for v2.4.
 
 i do not their intention/design, i am from warciv version.
 
   Is there any document describing the big picture for
  custom AI's? I have skipped through the latest source code a bit, seen
  the AI stub and ai.* files in the common dir, but I am not sure
  about each of these functions in detail,m when they are called, etc.
 
 i can not help there. Part of the AI is also CM(city Management).
 
  Also, I am new to Freeciv dev in general, have not worked on the code
  so far, only played the game in the past.
 
   What would be the best way
  of debugging my own development? When writing a new AI for Freeciv, I
  of course want to see how it works bit for bit, so a debugging feature
  would be very handy!
 
 recording/replaying would be very useful
 - for testing
 - for debugging
 
 Since CI/AI is a client thing, it means gui(graphic user interface) is
 in the way.

from received comments
- civserver is running the CI(computational Intelligence) code.
  because the CI is cheating, he is using all informations.
  That is the server play without even any client connected.
- civserver should start client processes.
  reason being that it is CI(computational intensive)
  if on same computer, use pipe not TCP.

 The easiest thing for debugging is to used two computers.
 That is, you do not want input to mess up the gui event loop.



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] Freeciv AI development

2012-09-17 Thread Marko Lindqvist
On 16 September 2012 15:52, Matthias F. Brandstetter m...@mabra.me wrote:
 Hi Freeciv Team!

 I am a PhD candidate at De Montfort University in UK, working on
 Computational Intelligence for Computer Games. For my current studies
 I am thinking of using Freeciv as test bed for my research on AI in
 games.

 On your web site I have seen that you are currently re-writing the AI
 code for v2.4.

 Actually, we've for most part ceased feature development for 2.4 last
November when we branched stable branch to make 2.4 releases from once
it gets stable enough. That AI reorganization was finished before
that, though, and in since then there has been only a litlle bit of
development on this field on trnk (from which next branch will be 2.5)

 That was not so much rewriting the AI code itself than reorganizing
how it gets called. AI code used to be mangled to all server code, now
things are more modular, AI code being separate from the other server
code. It was done in a way that completely new AI implementations can
be introduced as (loadable) modules - distinct players can use
distinct AI implementations. Server calls AI callback functions at
defined situations. Those callback functions for AI module to
implement are listed in common/ai.h. In addition to those callback
functions module needs to define just two functions, one to initialize
it and second to return its capability string for checking
compatibility between the server code and the module while loading the
module.

 Is there any document describing the big picture for
 custom AI's? I have skipped through the latest source code a bit, seen
 the AI stub and ai.* files in the common dir, but I am not sure
 about each of these functions in detail,m when they are called, etc.

 I'm afraid the documentation is still quite much lacking - so far
I've only added comments to common/ai.h about when each callback gets
called.

 As AI runs just as part of server binary, it has access to all the
data, freedom to modify it any way it wants, and to call any server
functions. This means that AI module can cheat as much as author dares
to make it to cheat. It also gives AI author responsibility not to
mess game state.

 Also, I am new to Freeciv dev in general, have not worked on the code
 so far, only played the game in the past. What would be the best way
 of debugging my own development? When writing a new AI for Freeciv, I
 of course want to see how it works  bit for bit, so a debugging feature
 would be very handy!

 There's no single catch-it-all feature for debugging. Depending on
what exactly I've wanted to know, I've combined several techniques. In
most cases you want to run autogames (games with no human players)
with predefined random seeds for reproducibility. You can run them in
debugger, collect logs (get familiar with logging macros in
utility/log.h) and compare results between original and modified AI,
creating starting situations in editor.

 That's the most general level view, feel free to ask more detailed
questions once you get yourself familarized with the code.


 - ML

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] Freeciv AI development

2012-09-16 Thread Matthias F. Brandstetter
Hi Freeciv Team!

I am a PhD candidate at De Montfort University in UK, working on
Computational Intelligence for Computer Games. For my current studies
I am thinking of using Freeciv as test bed for my research on AI in
games.

On your web site I have seen that you are currently re-writing the AI
code for v2.4. Is there any document describing the big picture for
custom AI's? I have skipped through the latest source code a bit, seen
the AI stub and ai.* files in the common dir, but I am not sure
about each of these functions in detail,m when they are called, etc.

Also, I am new to Freeciv dev in general, have not worked on the code
so far, only played the game in the past. What would be the best way
of debugging my own development? When writing a new AI for Freeciv, I
of course want to see how it works bit for bit, so a debugging feature
would be very handy!

Beside that, thanks for the great effort you put into Freeciv!

Kind regards, Matthias


-- 
Matthias F. Brandstetter
m...@mabra.me

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev