11# (c) 2022 Marcin "szczyglis" Szczygliński
22# GitHub page: https://github.com/szczyglis-dev/python-lanchester
334- # Version: 1.0.0
4+ # Version: 1.0.1
55# This package is licensed under the MIT License.
66# License text available at https://opensource.org/licenses/MIT
77
3535r_i = 4 # RED units information warfare ability coefficient
3636b_i = 4 # BLUE units information warfare ability coefficient
3737
38- # model select
3938def select_model ():
39+ """Select model"""
4040 global model
4141 n = int (
4242 input (
@@ -56,36 +56,48 @@ def select_model():
5656 select_model ()
5757
5858
59- # get integer input
60- def get_int (msg , current ):
59+ def get_int (msg : str , current : int ) -> int :
60+ """
61+ Get integer input
62+
63+ :param msg: message to display
64+ :param current: current value
65+ :return: integer value
66+ """
6167 n = int (input ("\n Enter {}: [current: {}]\n " .format (msg , current )) or current )
6268 print ("Current value: {}\n " .format (n ))
6369 return n
6470
6571
66- # get float input
67- def get_float (msg , current ):
72+ def get_float (msg : str , current : float ) -> float :
73+ """
74+ Get float input
75+
76+ :param msg: message to display
77+ :param current: current value
78+ :return: float value
79+ """
6880 n = float (input ("\n Enter {}: [current: {}]\n " .format (msg , current )) or current )
6981 print ("Current value: {}\n " .format (n ))
7082 return n
7183
7284
73- # get input params
7485def get_params ():
86+ """Get input parameters"""
7587 global R0 , B0 , T , dt , r_l , b_l , r_f , r_s , b_s , b_f , r_a , b_a , r_i , b_i
7688
77- # base parameters:
89+ # base parameters
7890 R0 = get_int ("number of RED units" , R0 )
7991 B0 = get_int ("number of BLUE units" , B0 )
8092 T = get_int ("total number of steps in the simulation" , T )
8193 dt = get_int ("time interval" , dt )
8294
83- # parameters for "linear" and "modernized" models:
95+ # parameters for "linear" and "modernized" models
8496 if model == "linear" or model == "modernized" :
8597 r_l = get_float ("combat efficiency of RED units" , r_l )
8698 b_l = get_float ("combat efficiency of BLUE units" , b_l )
8799
88- # parameters for "square" and "modernized" models:
100+ # parameters for "square" and "modernized" models
89101 if model == "square" or model == "modernized" :
90102 r_s = get_float (
91103 "average number of RED units that damage each other per unit of time" , r_s
@@ -94,7 +106,7 @@ def get_params():
94106 "average number of BLUE units that damage each other per unit of time" , b_s
95107 )
96108
97- # parameters for "modernized" model only:
109+ # parameters for "modernized" model only
98110 if model == "modernized" :
99111 r_f = get_float ("RED units camouflage ability factor" , r_f )
100112 b_f = get_float ("BLUE units camouflage ability factor" , b_f )
@@ -114,14 +126,14 @@ def get_params():
114126 get_input ()
115127
116128
117- # initialize
118129def get_input ():
130+ """Get input"""
119131 select_model ()
120132 get_params ()
121133
122134
123- # main app
124135def main ():
136+ """Main function"""
125137 print ("Lanchester's laws simulation, v.{}" .format (lanchester .__version__ ))
126138 print ("GitHub page: https://github.com/szczyglis-dev/python-lanchester\n " )
127139
@@ -162,7 +174,7 @@ def main():
162174 "\n \n [FINISHED] Do you want to try again?\n \n Type 'Y' to try again or any other char to exit\n "
163175 )
164176 if c == "Y" or c == "y" or c == "yes" :
165- main ()
177+ main () # try again
166178
167179
168180if __name__ == "__main__" :
0 commit comments