freeciv-python icon indicating copy to clipboard operation
freeciv-python copied to clipboard

Finalise the Structure of Package

Open yashbonde opened this issue 6 years ago • 1 comments

As first issue I wanted to raise a problem that I am facing on deciding the structure of the package. There are many possibilities of structures we can use for this project. Going over a few of them here:

  1. Complete re-writing in Cython: One option is to perform complete rewrite of original source code in Cython to give complete access to the game controls. Though this is not a bad idea and will [possibly] result in complete control of the game via python this is also a cumbersome process to do.

  2. Wrapper in Cython/pybind11: Another option is to only modify the source code so much that we have access to the client taps and have complete client side interface in python. This is doable and is one of the strong approaches.

  3. Writing socket Connection: This approach modifies the idea above by writing client side sockets in python and having all the required processing locally. This is the fastest the three but main issue while building this is the lack of proper documentation on the freeciv socket connections. For this particular approach I am taking inspiration from an already existing repo.

Till I get further response on this I am going to be developing on the lines of 3.

yashbonde avatar Dec 09 '18 17:12 yashbonde

For now I will be pushing with the third option, using socket connections using tornado to establish connection to the server. Another major update to this thread should be the addition of handlers and inference engines, the structure is as follows:

(AI) <--> World <--> Inference Engine <--> Packet Manager <--> Server

The world can be considered as nothing but the master handler which controls handlers which control the different inference engines. E.g. CityHandler handles all cities for the player, and each city is nothing but a single CityInferenceEngine which controls all the attributes for the city e.g. CityInferenceEngine.add_improvement(impr_key) to add improvement to the city like Hoover Dam etc.

The function add_improvement(impr_key) then sends a packet to the server using the IO Manager. This part is still a bit tricky because I am still writing the code for packet IO.

yashbonde avatar Jan 13 '19 06:01 yashbonde