RE: MLM Numbers Game
- Posted by Matthew Lewis <matthewwalkerlewis at YAHOO.COM> Oct 12, 2001
- 361 views
> -----Original Message----- > From: C. K. Lester [mailto:cklester at yahoo.com] > I used a test value of 10556. This should give us a General > with one FULL > leg. Your program worked fine {10000, 500, 50, 5, 1}. If you > use 10557, > however, you get TWO Generals! This extra guy should be in > the soldiers > tier. D'oh! I thought I could simply get away by checking the lowest rank. This should work: -- next calculate amount of each for a population while ix and pop do if ix < length( actual ) then actual[ix+1] += 1 pop -= 1 -- account for overflow end if --**************DELETE THIS**************-- -- ensures no partial lowest ranks if ix = 1 then actual[2] -= 1 pop += 1 end if --***************************************-- quo = floor( pop / amount[ix] ) --**************CHANGE THIS**************-- if quo then sum = quo actual[ix] += sum pop -= sum for i = ix-1 to 1 by -1 do sum *= required[i+1] pop -= sum actual[i] += sum end for else pop += 1 actual[ix+1] -= 1 end if --************************************-- --pop = remainder( pop , amount[ix] ) ix -= 1 end while if ix > 1 then actual[ix] -= end if > Is it possible to manage the matrix itself in a sequence > variable? This > might allow us to actually PLACE units instead of estimate > where they'd > be... I don't think you'd want something like that. Seems too difficult to manage. However, you might set up something like an EDS table or simlply use a-lists (EDS would probably be better for large populations, but Jiri's a-list code is pretty easy to use): The key could be a name or whatever. You'd also store the rank, 'parent' and 'children'. I'll simply put the 'key' as the first sequence element: {key, Rank, Parent, {Children (immediate)} {Gen1, 5, {}, {Capt1, Capt2, Capt3, Capt4, Capt5}} {Capt1, 4, Gen1, {lt1, lt2,...}} Now, you can find/add/delete as you like, and you can also assemble a tree of people rather easily. Of course, if you delete, you'll need to remember to update parent/children according to the rules of the organization (ie, do you inheirit the children of a deleted child?} Matt Lewis