collecting ideas for new fields

For what's not in 'Top Priority Game Design'. Post your ideas, visions, suggestions for the game, rules, modifications, etc.

Moderator: Oberlus

Message
Author
User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: collecting ideas for new fields

#31 Post by LienRag »

Ophiuchus wrote: Mon Jul 19, 2021 7:16 pm
LienRag wrote: Mon Jul 19, 2021 6:39 pmIs there a way to prevent that ?
Lower the probability of the fields occuring
Where is that probability coded ?

If it's in the FOCS file, I haven't been able to find it.
The only random part there I was able to spot is about the field size...

In the python file, I just added the name of the file, I don't understand the rest of the code.

User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: collecting ideas for new fields

#32 Post by LienRag »

Ophiuchus wrote: Mon Jul 19, 2021 7:21 pmIf specials are too rare, how about a certain planet or star type(s)?
I really wanted to have things conditional on being on a double-star system, but I wasn't able to test for that in FOCS.

I believe that using Special is the best idea here though, since a player can rely on it and then, as you wrote, use the corresponding ships when the right field appear.
So the field would be the major use for the ship, but the ship would still not be useless outside of it (though its use will be limited then to defending the special).

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

Re: collecting ideas for new fields

#33 Post by Ophiuchus »

LienRag wrote: Mon Jul 19, 2021 7:40 pm Where is that probability coded ?
You are right, I mixed this up with specials.
You could use a special to control spawning like it is done for the ACCRETION_DISC_SPECIAL though if you want to do it from FOCS.

Looks like the universe fields are generated in execute_turn_events() in turn_events.py and it looks it creates one field each turn. So maybe your fields are just big or living too long so they dominate the screen. Of course you could fiddle with the python script.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: collecting ideas for new fields

#34 Post by LienRag »

Ophiuchus wrote: Tue Jul 20, 2021 5:22 am Looks like the universe fields are generated in execute_turn_events() in turn_events.py and it looks it creates one field each turn.
Oh, so the universe creates one field per turn, at random between the existing fields ?
That's actually what I want it to do, so you may be right, the problem may be the size of my fields...

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

Re: collecting ideas for new fields

#35 Post by Geoff the Medio »

Ophiuchus wrote: Mon Jul 19, 2021 7:16 pm
LienRag wrote: Mon Jul 19, 2021 6:39 pmIs there a way to prevent that ?
Lower the probability of the fields occuring
Or add a limit checking the number of roaming fields in the activation condition of field spawner effects.

User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: collecting ideas for new fields

#36 Post by LienRag »

So, after Ophiuchus' answer, I believe that I found the code responsible for Field creation ?

Code: Select all

    if random() < max(0.00015 * radius, 0.03):
        field_type = choice(field_types)
        size = 5.0
        x = y = radius
        dist_from_center = uniform(0.35, 1.0) * radius
        angle = random() * 2.0 * pi
        x = radius + (dist_from_center * sin(angle))
        y = radius + (dist_from_center * cos(angle))

        print("...creating new", field_type, "field, at distance", dist_from_center, "from center")
        if fo.create_field(field_type, x, y, size) == fo.invalid_object():
            print("Turn events: couldn't create new field", file=sys.stderr)
        

(with radius = fo.get_universe_width() / 2.0 before in the Python file)

The Field creation happens with fo.create_field, which is called only in a test.
IIRC in Python, calling it in a test actually calls it (I mean, testing if fo.create_field () == something means that fo.create_field is executed, and then its result tested against the "something" condition) ?
Is the fo.create_field function also Python or C++ ?

So a field is indeed created once at a time, but not once a turn, once each time the random number generator gets under 3% or under universe_width*0,00015. Which means that to reach once a turn universe_width must be over 6000 (what's the unit for universe_width by the way ?).

Why does it initialize x and y with the "radius" value and then never uses it before re-initializing them with a more sensible value ?

Is there a problem in the RNG ? Because the code should not bring multiple fields at the same starting location, while in game that is what seems to happen...

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

Re: collecting ideas for new fields

#37 Post by Ophiuchus »

LienRag wrote: Tue Jul 20, 2021 6:51 pm So, after Ophiuchus' answer, I believe that I found the code responsible for Field creation ?
yes. Note: execute_turn_event() is called once per turn after production and before population growth in ServerApp.cpp ExecuteScriptedTurnEvents.
LienRag wrote: Tue Jul 20, 2021 6:51 pm Is the fo.create_field function also Python or C++ ?
it is python wrapped c++ code

Code: Select all

$ grep -r create_field freeorioncombat
freeorioncombat/server/ServerWrapper.cpp:        py::def("create_field",                     CreateField);
freeorioncombat/server/ServerWrapper.cpp:        py::def("create_field_in_system",           CreateFieldInSystem);
LienRag wrote: Tue Jul 20, 2021 6:51 pm So a field is indeed created once at a time, but not once a turn, once each time the random number generator gets under 3% or under universe_width*0,00015.
But that roll is done once per turn AFAICS. So at maximum one new field per turn.
LienRag wrote: Tue Jul 20, 2021 6:51 pm what's the unit for universe_width by the way ?
i guess uU, same as X,Y coordinates or ship speed
LienRag wrote: Tue Jul 20, 2021 6:51 pm Why does it initialize x and y with the "radius" value and then never uses it before re-initializing them with a more sensible value ?
leftover i guess. probably was intended to put the field in the middle of the universe before shifting it. that radius should be rather called universe_radius
LienRag wrote: Tue Jul 20, 2021 6:51 pm Is there a problem in the RNG ? Because the code should not bring multiple fields at the same starting location, while in game that is what seems to happen...
why you think that? there is nothing to stop it from bringing in multiple fields at the same location. the code only prevents fields from starting too close to the center.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: collecting ideas for new fields

#38 Post by LienRag »

Ophiuchus wrote: Wed Jul 21, 2021 8:00 am
LienRag wrote: Tue Jul 20, 2021 6:51 pm Is there a problem in the RNG ? Because the code should not bring multiple fields at the same starting location, while in game that is what seems to happen...
why you think that? there is nothing to stop it from bringing in multiple fields at the same location. the code only prevents fields from starting too close to the center.
Well, nothing except the "random" part in "random number generator"...

I understand that random can randomly makes field start very close from the last one, but the probability for that seems very low while I have seen this behavior in many games.
I did not make exact statistical measurements though, that's why I'm asking the question whether someone assessed the actual randomness of the RNG, since getting random numbers on a computer can be tricky.

User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: collecting ideas for new fields

#39 Post by LienRag »

Ophiuchus wrote: Wed Aug 04, 2021 9:17 am [*]content: Meteor Blizzard size shrinks when ships are inside (geoff)
Brilliant idea indeed.

Though, I'm not sure that it will improve the game if the shrinking effect of ships starts at the beginning of the Field : the main problem of these Blizzard fields is that they reward "being there" rather than careful planning and good strategy.
It has been partially solved by their better speed, but if they shrink early it will be a no-brainer to put ships in the field while you can and that will deprive players farther in the Galaxy of the ability to exploit these fields even through the most brilliant strategy.

If they shrink only after, say, twenty turns, then (with good speed) they'll be across a reasonable Empire's territory before shrinking, which means that all players around will have time to plan their actions accordingly.

I repeat my other point about these fields : is it possible technically to make them seen on the Galaxy Map even to players who have not explored the region ?
Maybe conditional on a Tech (like Gravitonics) ?
Or to have "Science ships" that have a huge detection range, but only for fields (i.e, they do not detect fleets or stars/planets in this detection range, except of course inside the regular detection range of the ship that bear that part) ?

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

Re: collecting ideas for new fields

#40 Post by Ophiuchus »

LienRag wrote: Tue Aug 10, 2021 6:08 pmI repeat my other point about these fields : is it possible technically to make them seen on the Galaxy Map even to players who have not explored the region ?
Maybe conditional on a Tech (like Gravitonics) ?
Or to have "Science ships" that have a huge detection range, but only for fields (i.e, they do not detect fleets or stars/planets in this detection range, except of course inside the regular detection range of the ship that bear that part) ?
from technical standpoint: yes, yes, yes

basically you would have to script giving visibility outside of the detection mechanism (using the SetVisibility effect).
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
LienRag
Cosmic Dragon
Posts: 2148
Joined: Fri May 17, 2019 5:03 pm

Re: collecting ideas for new fields

#41 Post by LienRag »

What is the point of Field Repellers as buildings ?
It prevents any interesting idea about new fields with detrimental consequences, as the obvious answer will be to build a Field Repeller when one's planets are on its way...

Post Reply