EL formula help...

Valdier

Explorer
I am currently working on a monster database with a web front end... I have gotten to the point where I am mostly finished with my 1.0 design...

The final stage I am at is generating an estimated EL for an unlimited number of monsters.

I am currently thinking something along these lines. (no specific language in the example- using java though)

int elArray[];
int a;
int b;

while(combinedTwoCR's){
for(int i = 0; i < elArray.length; i++){
for(int j = 0; j < elArray.length; i++){
//pseudo code now
if a(+/- 1) = b (+/- 1)
delete a,
delete b,
add(new a+2(+/- 1))
start again... until no combined then take the highest value and call it the EL

}
}

Anyone already write a formula for this? the important part being that it will work with any number of monsters of any CR.

a preview of the program can be seen at:

www.valdier.com/backup/monsterFinder

feel free to email me if you have any suggestions. I am not an algorithm person :)
 

log in or register to remove this ad

Valdier

Explorer
Ok so after sleeping and talking to a friend I realized half of what I am doing is a waste of time :)

I will post my final formula here when I am done.
 

Valdier

Explorer
Ok, so here is the final formula I used for determining EL's in case anyone cares :)
(Note it is in java)

public static Integer calculate(ArrayList list){

int current;
int next;
int temp;

while(list.size() > 1){
java.util.Collections.sort(list);

current = ((Integer)list.get(0)).intValue();
next = ((Integer)list.get(1)).intValue();

if((current == next) || (current + 1 == next)){
temp = current;
list.remove(0);
list.remove(0);
list.add(new Integer(temp + 2));
}
else{
list.remove(0);
}
}
return (Integer)list.get(0);
}



If anyone has any comments feel free to send them
 


dvvega

Explorer
Couple of comments ...

1) your monster list "screws up" under certain conditions ...

Example: select CR and Cold climate, click search. I get a list.
Select the Bear, Polar at the top and add to encounter. All the monsters up to (not including) ettin are removed from the list. So I cannot add another bear, or any dragons for example.

I did some more testing, and it's almost as if you're "dropping" the first two monsters after a transaction.

Perhaps you should allow the user to type in a number next to the monster desired??

2) the EL calculation is wrong, in some cases. In particular for mixed pairs of CRs (pg 101, DMG).

Example: take two monsters, one CR 14, one CR 16 (Two Bronze Dragons, one an Adult, one a Mature Adult).

Your value for EL = 16. The correct value should be 17.
 

Leopold

NKL4LYFE
now if only there were a way to add in manual CR's and come out with the total. I LOVE the breakdown of xp by classes. Is there a way to space it out even more? LIke get a chart from 1-10 and than go forward to 11-20?


I like it very nice just add some customizations and it will be a staple of my gaming computer!!
 

MonkeyBoy

First Post
ahem...

you should split apart the list handling from the calculation. e.g.

(treat this a pseudo-code, me no do java no more...)

int getELFrompair(int a, int b)
{
 if((a == b) || ((a + 1) == b))
 {
  return a+2;
 }
 else
 {
  return b;
 }
}

int getELFromList(list theList)
{
 int temp;
 while(theList.length > 1)
 {
  temp = getElFromPair(theList(0), theList(1));
  theList.delete(0);
  theList(0) = temp;
 }
 return theList(0);
}

you should probably also be working on a copy of the list rather than destroying it as you go??

this means that you can then re-use your EL combination code without being tied to a list implementation...

and that'll make correcting slight errors in the combination code easier...
 
Last edited:

MonkeyBoy

First Post
right...

OK, quick nip to the car-park later...

it appears that what you actually need to do is somewhat more complex...

this is somewhat pseudocode-like.

(once you have your list to work on)

look at the head of the list
search the rest of the list for
either;
a matched CR
or;
a CR 2 points lower than the head
if you find one;
delete both the head and the pair node
if you had a match, replace with a single entry with CR = HeadCR + 2
if it was a pair with CR 2 lower replace with a single entry with CR = HeadCR + 1

repeat this until you cannot find a suitable pair for the head, or until the list is one long

if you cannot match the head, you must then try again on the rest of the list without the head

Now; each time you reduce, you have to start again on the WHOLE list - you treat a combined CR as a single creature, so that allows you to revisit "irreducible" CRs later.

I suggest you use recursion to do this - your end case for any recursion wants to be whenever a reduction is made

There may come a point where you cannot reduce the list; the rules approach this from the opposite (easier) direction, assuming you will construct an encounter from CRs rather than wanting to build the CR / EL from the encounter.

There also rises the spectre of having lists that reduce only if tackled in a specific order...

Your other option is to invent a mechanism yourself which WILL reduce all lists, i.e. to plug the gaps

Good Luck!
 

MonkeyBoy

First Post
further

to reduce the chances of being unable to reduce the list, you need to find an orderin which to process the entries which raises the lower CRs towards the higher.

therefore i suggest you sort the list in ascending order before beginning (which i think you were, on reflection)

but, you may need to do a search to find the "best next reduction" in order to work towards constructing combined CRs which are equal to or 2 less than another higher in the list.

suddenly this looks non-trivial, neh?
 

MonkeyBoy

First Post
ahem...

you might like to take a look at this (dusted off my java books, you got me interested you see...)

Its just a noddy class to try out my pseudo code above, seems to pas a first-glance look :)
 

Attachments

  • elcombinator.zip
    1.7 KB · Views: 3,139

Remove ads

Top