Potential replacement of FOCS with Python

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderators: Committer, Committer

Message
Author
User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12380
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Potential replacement of FOCS with Python

#16 Post by Geoff the Medio » Mon Oct 24, 2016 1:10 pm

em3 wrote:My 2c: Value could be made of type with __add__ and __radd__ methods overloaded...
Note that the current implementation has arbitrary parameters for what value = is set to... it can be just Value, or Value + 5, or Max(Value, 5), or Value*3 + 1, or sin(Value^log(Value)), or various other complicated expressions... Point being, don't just think of needing to overload the add methods due to that being the most common case.

User avatar
em3
Vacuum Dragon
Posts: 570
Joined: Sun Sep 25, 2011 2:51 pm

Re: Potential replacement of FOCS with Python

#17 Post by em3 » Mon Oct 24, 2016 1:55 pm

Geoff the Medio wrote:Note that the current implementation has arbitrary parameters for what value = is set to... it can be just Value, or Value + 5, or Max(Value, 5), or Value*3 + 1, or sin(Value^log(Value)), or various other complicated expressions... Point being, don't just think of needing to overload the add methods due to that being the most common case.
I just wanted to note, that example created by adrian_bother could be discouraging to some people because of the syntax:

Code: Select all

Set("Detection", Add(Value, 10))
, and that it can be simplified - actual arithmetic operation could be used instead of the lengthy "functions", like Add, Multiply etc. Granted, some of these functions would have to stay (Max, Sin, Log, ...).

I understand, that designing everything about potential foss replacement in python is a bit too soon, as far as this discussion is concerned. I just wanted to make it sound like a better idea to people that would be bothered by the implied complexity.
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

spikethehobbit
Space Squid
Posts: 58
Joined: Mon Aug 27, 2012 7:24 pm

Re: Potential replacement of FOCS with Python

#18 Post by spikethehobbit » Tue Oct 25, 2016 12:07 am

Effects groups could be made callable. That would eliminate any special handling or typing requirements.

Code: Select all

Special(
    name = "WORLDTREE_SPECIAL",
    description = "WORLDTREE_SPECIAL_DESC",
    stealth = 0,
    spawnrate = 1.0,
    spawnlimit = 1,
    location = lambda planet: (
        isinstance(planet, Planet)
        and (planet.planet_type not in [PlanetType.Asteroids, PlanetType.GasGiant, PlanetType.Inferno])
        and (planet.size not in [PlanetSize.TINY, PlanetSize.HUGE])
        and not (within_starlane_jumps(planet, jumps=2, condition=lambda system: (
            isinstance(system, System)
            and not [planet2 for planet2 in system.planets if planet2.owner]
            )))),
)
All contributions are submitted under GPL or LGPL v2 or later, or under appropriate Creative Commons licence, consistent with project guidlines.

User avatar
em3
Vacuum Dragon
Posts: 570
Joined: Sun Sep 25, 2011 2:51 pm

Re: Potential replacement of FOCS with Python

#19 Post by em3 » Tue Oct 25, 2016 10:07 am

spikethehobbit wrote:Effects groups could be made callable. That would eliminate any special handling or typing requirements.

Code: Select all

[...]
I think the whole point is for effects to not be executed in python, just constructed from python scripts (compiled into already existing engine structures).
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

spikethehobbit
Space Squid
Posts: 58
Joined: Mon Aug 27, 2012 7:24 pm

Re: Potential replacement of FOCS with Python

#20 Post by spikethehobbit » Wed Oct 26, 2016 2:35 am

em3 wrote:
spikethehobbit wrote:Effects groups could be made callable. That would eliminate any special handling or typing requirements.

Code: Select all

[...]
I think the whole point is for effects to not be executed in python, just constructed from python scripts (compiled into already existing engine structures).
Fair enough.
All contributions are submitted under GPL or LGPL v2 or later, or under appropriate Creative Commons licence, consistent with project guidlines.

o01eg
Programmer
Posts: 337
Joined: Sat Dec 10, 2011 5:46 am

Re: Potential replacement of FOCS with Python

#21 Post by o01eg » Sun May 05, 2019 9:20 am

em3 wrote:
Tue Oct 25, 2016 10:07 am
spikethehobbit wrote:Effects groups could be made callable. That would eliminate any special handling or typing requirements.

Code: Select all

[...]
I think the whole point is for effects to not be executed in python, just constructed from python scripts (compiled into already existing engine structures).
It's a little necroposting but there are AST modules for Python 2 and Python 3: https://docs.python.org/3/library/ast.html https://docs.python.org/2/library/ast.html
Gentoo Linux x64, gcc-8.3, boost-1.65.0
Ubuntu Server 18.04 x64, gcc-7.4, boost-1.65.1
Welcome to slow multiplayer game at freeorion-lt.dedyn.io. Version 2019-06-03.8193654.
Donates are welcome: BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK

User avatar
Oberlus
Cosmic Dragon
Posts: 1222
Joined: Mon Apr 10, 2017 4:25 pm

Re: Potential replacement of FOCS with Python

#22 Post by Oberlus » Sun May 05, 2019 9:48 am

o01eg wrote:
Sun May 05, 2019 9:20 am
It's a little necroposting
No really. It's been mentioned recently the common desire to substitute FOCS with Python for several reasons (compilation time and requirements, many more people know Python than FOCS, ...). So good to resurrect this.

Ophiuchus
Programmer
Posts: 838
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Potential replacement of FOCS with Python

#23 Post by Ophiuchus » Sun May 05, 2019 6:30 pm

o01eg wrote:
Sun May 05, 2019 9:20 am
em3 wrote:
Tue Oct 25, 2016 10:07 am
spikethehobbit wrote:Effects groups could be made callable. That would eliminate any special handling or typing requirements.

Code: Select all

[...]
I think the whole point is for effects to not be executed in python, just constructed from python scripts (compiled into already existing engine structures).
It's a little necroposting but there are AST modules for Python 2 and Python 3: https://docs.python.org/3/library/ast.html https://docs.python.org/2/library/ast.html
As far as i get it these modules are for accessing the python a.syntax tree. So usuable for tools and metaprogramming python. I dont see how these help in generating/metaprogramming FOCS (?)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

o01eg
Programmer
Posts: 337
Joined: Sat Dec 10, 2011 5:46 am

Re: Potential replacement of FOCS with Python

#24 Post by o01eg » Sun May 05, 2019 6:36 pm

Ophiuchus wrote:
Sun May 05, 2019 6:30 pm
o01eg wrote:
Sun May 05, 2019 9:20 am
em3 wrote:
Tue Oct 25, 2016 10:07 am

I think the whole point is for effects to not be executed in python, just constructed from python scripts (compiled into already existing engine structures).
It's a little necroposting but there are AST modules for Python 2 and Python 3: https://docs.python.org/3/library/ast.html https://docs.python.org/2/library/ast.html
As far as i get it these modules are for accessing the python a.syntax tree. So usuable for tools and metaprogramming python. I dont see how these help in generating/metaprogramming FOCS (?)
I suppose this is the entire thread about replace FOCS with Python.
Gentoo Linux x64, gcc-8.3, boost-1.65.0
Ubuntu Server 18.04 x64, gcc-7.4, boost-1.65.1
Welcome to slow multiplayer game at freeorion-lt.dedyn.io. Version 2019-06-03.8193654.
Donates are welcome: BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK

Ophiuchus
Programmer
Posts: 838
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Potential replacement of FOCS with Python

#25 Post by Ophiuchus » Sat May 11, 2019 9:08 am

o01eg wrote:
Sun May 05, 2019 6:36 pm
Ophiuchus wrote:
Sun May 05, 2019 6:30 pm
o01eg wrote:
Sun May 05, 2019 9:20 am


It's a little necroposting but there are AST modules for Python 2 and Python 3: https://docs.python.org/3/library/ast.html https://docs.python.org/2/library/ast.html
As far as i get it these modules are for accessing the python a.syntax tree. So usuable for tools and metaprogramming python. I dont see how these help in generating/metaprogramming FOCS (?)
I suppose this is the entire thread about replace FOCS with Python.
Yes, but you do not answer my question/the topic.


The OP is about replacing FOCS as a text format. (For me extending the capabilities would actually be enough).
Python would be used to generate definition structure which we could freeorion content [abstract syntax] tree (FOCT/FOCAST)?

So we are talking about FOCAST not python AST.

I will rephrase:

As far as i get it these modules are for accessing the python a.syntax tree. So usuable for tools and metaprogramming python. I dont see how these help in generating/metaprogramming freeorion content.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Furthermore, I propse... we should default to four combat rounds instead of three ...for the good of playerkind.

Post Reply