Re: Army Composition

new topic     » goto parent     » topic index » view thread      » older message » newer message

C.K.,

The number "10556" was  calculated by simple algebra:

--Soldiers - no requirements
--Squad Leader - commands 20 soldiers
--Lt. - commands 10 Squad Leaders
--Captain - commands 10 Lt.s
--General - commands 5 Captains


-- soldiers + squad leaders + Lts. + Captains + Generals = Population
(army!)
--s + (s/20) + ((s/20)/10) + (((s/20)/10)/10 ) + ((((s/20)/10)/10)/5)= P
-- s + s/20  +  s/200 +  s/2000  + s/10000 = p
-- 10000s + 500s + 50s + 5s + s = 10000p
-- 10556s = 10000p
-- s = 1000p/10556


I don't understand what you mean by "4 levels and 6 levels" of rank.  You
only specified 5 levels of rank.

If you want to find out how many different ranks there are, just look at
each rank var, if not zero, increment a "NumberOfRanks" counter.

I didn't really understand what you're doing with the matrix, either, and
the change in your rank system,
ranks = { "Soldier" , "Leader" , "Captain" , "Sergeant" , "General" }
seems wrong, it should be:
ranks = { "Soldier" , "Leader" , "Sergeant" ,"Captain"  , "General" }

Can you explain more about what you mean by
"determine at
> -- run time the number of different "levels" of rank."
if it's not what I suggested above?

Dan


----- Original Message -----
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, October 10, 2001 7:41 PM
Subject: RE: Army Composition


>
> Okay, Dan, I've made a few modifications to your code. Let me know what I
> need to do to resolve the questions I've peppered therein... :)
>
> --<code begins>
> include get.e
> include misc.e
>
> function product( sequence x )
> atom prod
> prod = x[1]
> for t=2 to length(x) do
> prod = prod * x[t]
> end for
> return prod
> end function
>
> integer s, sql,lt,cp,gn, p, total, matrixLeg
> sequence matrix, ranks
>
> -- I eventually want to be able to determine at
> -- run time the number of different "levels" of rank.
> -- For instance, I'd like to run stats on 4 levels
> -- and 6 levels of rank for a given population.
> -- So, instead of s, sql, lt, cp, and gn, I'll have
> -- Level[1], Level[2], Level[3],..., Level[n]
>
> ranks = { "Soldier" , "Leader" , "Captain" , "Sergeant" , "General" }
> matrix = { 1, 20 , 10 , 10 , 5 }
>
> if length(ranks) != length(matrix) then
> puts(1,"ERROR! Length of ranks does not equal length of matrix.\n")
> abort(0)
> end if
>
> matrixLeg = product( matrix )
>
> while 1 do
> p = prompt_number("enter the population of soldiers (0=quit): " ,
> {0,1073741823} )
>
> if p=0 then exit end if
>
>  s = floor(matrixLeg*p/10556) -- how is 10556 calculated?
>  sql = floor(s/matrix[2])
>  lt = floor(sql/matrix[3])
>  cp = floor(lt/matrix[4])
>  gn = floor(cp/matrix[5])
>
> total = s+sql+lt+cp+gn
> s = s + (p-total)
>
> puts(1, "matrixLeg: " & sprint(matrixLeg) & "\n")
> puts(1, "population: " & sprint(p) & "\n")
> puts(1, ranks[1]&"(s): " & sprint(s) & "\n")
> puts(1, ranks[2]&"(s): " & sprint(sql) & "\n")
> puts(1, ranks[3]&"(s): " & sprint(lt) & "\n")
> puts(1, ranks[4]&"(s): " & sprint(cp) & "\n")
> puts(1, ranks[5]&"(s): " & sprint(gn) & "\n")
> puts(1, "total: " & sprint( s + sql + lt + cp + gn) & "\n")
>
> end while
>
> --<code ends>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu