Package horizons :: Package util :: Package python
[hide private]
[frames] | no frames]

Package python

source code

Put all code here that is not directly related to the game, but rather a generic enhancement of the programming language.

Submodules [hide private]

Classes [hide private]
  Const
An immutable type.
Functions [hide private]
 
get_all_subclasses(cls)
Recursivly find all subclasses of a given class.
source code
float
map_balance(value, n, m)
Maps balance value defined in codomain of [1/n, n] for n >= 1, into linear balance (codomain of [-m, m]), having 1.0 as equal point for n-based balance, and 0.0 as equal point for linear balance.
source code
 
parse_port(port, allow_zero=True)
str2int for network ports.
source code
 
trim_value(value, min, max) source code
Variables [hide private]
  __package__ = 'horizons.util.python'
Function Details [hide private]

map_balance(value, n, m)

source code 

Maps balance value defined in codomain of [1/n, n] for n >= 1, into linear balance (codomain of [-m, m]), having 1.0 as equal point for n-based balance, and 0.0 as equal point for linear balance.

Parameters:
  • value (float) - value to be mapped
  • n (float) - fraction denominator
  • m (float) - linear boundary
Returns: float
value mapped into new balance type

parse_port(port, allow_zero=True)

source code 

str2int for network ports. Throws ValueError in case of error.