Math of Freeciv

Various topics about the game, the website, or anything else Freeciv related that doesn't fit elsewhere.
User avatar
dunnoob
Elite
Posts: 326
Joined: Mon Dec 23, 2013 3:13 am
Location: Hamburg
Contact:

Math of Freeciv

Postby dunnoob » Tue Oct 17, 2017 5:03 am

If you want a link from the Wiki to OEIS (On-Line Encyclopedia of Integer Sequences), there is now a template:oeis as a workaround for [s]FANDOM[/s]Wikia's broken [[OEIS:interwiki prefix]]. Tested on radius, some rather hopeless ASCII art trying to explain city_radius_sq and vision_radius_sq for topologies with squares instead of hexes.

There might be more interesting integer sequences on the Math of Freeciv page. And there is a not yet implemented SPECENUM hidden in many terrain.ruleset parameters:

Code: Select all

[parameters]

; The percentage of not-xyz tiles required to be adjacent to a given xyz
; tile, before it can be transformed into a not-xyz tile, and where xyz
; can be water, land, frozen, or thawed, e.g., "not-water" yields land.
; The default 101 means "nowhere", because more than all adjacent tiles is
; impossible.  Likewise 0 means "anywhere" (always possible) and does not
; depend on adjacent tiles.  Percentages from 1 to 100 are rounded for the
; topology; 8 squares or 6 hexes can be adjacent tiles:
;        0: anywhere            [0/6]  1 .. 12: 1 square  (1 hex)   [1/8]
; 13 .. 16: 2 squares (1 hex)   [1/6] 17 .. 24: 2 squares (2 hexes) [2/8]
; 25 .. 33: 3 squares (2 hexes) [2/6] 34 .. 37: 3 squares (3 hexes) [3/8]
; 38 .. 50: 4 squares (3 hexes) [3/6] 51 .. 62: 5 squares (4 hexes) [5/8]
; 53 .. 66: 6 squares (4 hexes) [4/6] 67 .. 74: 6 squares (5 hexes) [6/8]
; 75 .. 83: 7 squares (5 hexes) [5/6] 84 .. 87: 7 squares (6 hexes) [7/8]
; 88 ..100: 8 squares (6 hexes) [6/6]      101: nowhere (default)   [9/8]

ocean_reclaim_requirement = 30  ; water to land, classic 30: 3 sq. or 2 hex
land_channel_requirement= 15    ; land to water (classic 10: 1 tile)
thaw_requirement        =  0    ; \/ added in 2.6: frozen to thawed
freeze_requirement      =  0    ; /\ added in 2.6: thawed to frozen

Instead of a slightly obscure 0..101 value an enumeration of 14 values (4 bits incl. a reserve for unknown+error) would be good enough, but I found no nice names for a feature request. ;)

cazfi
Elite
Posts: 1536
Joined: Tue Jan 29, 2013 6:54 pm

Re: Math of Freeciv

Postby cazfi » Tue Oct 17, 2017 5:46 am

dunnoob wrote:Instead of a slightly obscure 0..101

That's percentage (101 being 100% even if rounding errors happen, I guess)

User avatar
dunnoob
Elite
Posts: 326
Joined: Mon Dec 23, 2013 3:13 am
Location: Hamburg
Contact:

Re: Math of Freeciv

Postby dunnoob » Tue Oct 17, 2017 7:26 am

cazfi wrote:That's percentage (101 being 100% even if rounding errors happen, I guess
Yes, a percentage, but the default 101 is intentionally used as a value for an impossible more than all case: more than 100% of the adjacent tiles (either more than six hexes, or more than eight squares). :ugeek:

User avatar
VladimirSlavik
Posts: 46
Joined: Thu Aug 27, 2015 7:27 am

Re: Math of Freeciv

Postby VladimirSlavik » Tue Oct 17, 2017 9:09 am

Computers have been born with an inherent disdain for symbolic math: Integer and floating point maths are outright masochistic if you care for exact numbers. Forget the nice identities that the theory of mathematics gives you - embrace the 101% that makes it work ;-)

User avatar
dunnoob
Elite
Posts: 326
Joined: Mon Dec 23, 2013 3:13 am
Location: Hamburg
Contact:

Re: Math of Freeciv

Postby dunnoob » Tue Oct 17, 2017 11:07 am

VladimirSlavik wrote:embrace the 101% that makes it work ;-)
Meh, even signed char can do 0..127, and 7 bit fans could try unsigned char. There is now some support for float in registry-INI files, but I'm not yet ready to embrace that, it could have strange side-effects. :lol:

Updated some days later: 7 bits as in 7E1 (serial communication, 7 data bits + one Even parity bit), there never was a byte with 7 bits, they always were octets or seriously more than 8 bits; see the hilarious RFC about Unicode in nonets (9 bits).
Last edited by dunnoob on Sat Oct 21, 2017 8:19 pm, edited 1 time in total.

User avatar
Corbeau
Elite
Posts: 805
Joined: Mon Jan 13, 2014 11:13 pm

Re: Math of Freeciv

Postby Corbeau » Tue Oct 17, 2017 11:10 am

VladimirSlavik wrote:Computers have been born with an inherent disdain for symbolic math: Integer and floating point maths are outright masochistic if you care for exact numbers. Forget the nice identities that the theory of mathematics gives you - embrace the 101% that makes it work ;-)

Added to "quotes to be remembered" :D