Skip to content

Commit d6117f5

Browse files
committed
Updated comments
1 parent 5d33bc9 commit d6117f5

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

app.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (c) 2022 Marcin "szczyglis" Szczygliński
22
# GitHub page: https://github.com/szczyglis-dev/python-lanchester
33
4-
# 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

@@ -35,8 +35,8 @@
3535
r_i = 4 # RED units information warfare ability coefficient
3636
b_i = 4 # BLUE units information warfare ability coefficient
3737

38-
# model select
3938
def 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("\nEnter {}: [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("\nEnter {}: [current: {}]\n".format(msg, current)) or current)
6981
print("Current value: {}\n".format(n))
7082
return n
7183

7284

73-
# get input params
7485
def 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
118129
def get_input():
130+
"""Get input"""
119131
select_model()
120132
get_params()
121133

122134

123-
# main app
124135
def 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\nType '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

168180
if __name__ == "__main__":

0 commit comments

Comments
 (0)