Welcome to Gaia! ::

Why Not?

Back to Guilds

No rules, just Fun! Join today. 

Tags: Roleplaying, Polls, Spam 

Reply "TIZ" This... is... zOMG!!
Formula for overall CL Goto Page: [] [<] 1 2

Quick Reply

Enter both words below, separated by a space:

Can't read the text? Click here

Submit

Nadian
Crew

PostPosted: Sat Nov 22, 2008 12:41 pm
I suppose I'm done writing the program I wanted to. It has two capabilities:

-It can tell you the overall CL of a given set of rings.
-It can plan a level-up strategy for you.


The only problem is that you'll only be able to run it if you have the ability to compile Java code on your machine. I guess I won't worry about that and I'll just demonstrate it working.



Finding overall CL
Specifically, run the Rings class with the ring CLs as its parameters. More generally, you type something like this from the command prompt:

java Rings 5.0 4.0 4.0 3.0 4.0 5.0 4.0 4.0


and it'll give you the results:

/Users/ekraft/ekraft/gaia/zomg > java Rings 5.0 4.0 4.0 3.0 4.0 5.0 4.0 4.0
Overall CL: 4.4
(Exact value: 79/18)
Total orbs: 530


If it's easier for you, you can give the name of each ring (although it doesn't make a difference here):


/Users/ekraft/ekraft/gaia/zomg > java Rings SharkAttack=5.0 Hack=4.0 Slash=4.0 KeenAye=3.0 Mantis=4.0 Dervish=5.0 Shuriken=4.0 Ghost=4.0
Overall CL: 4.4
(Exact value: 79/18)
Total orbs: 530


(Ring names cannot have spaces, numbers, or symbols so stick with uppercase and lowercase letters. 3nodding )

As you can see, both pieces of code report exactly the same thing so you can use whichever helps you the most. smile



Level Up Planning
Okay, I mentioned the optimal use of orbs from before... optimal from the point of view of obtaining the highest overall CL. This program also has the ability to figure that out as well, even from your own randomly-constructed set!


As a nice simple example, here's what it tells me about my current set:
/Users/ekraft/ekraft/gaia/zomg > java Planner Mantis=8.0 Bump=8.0 Diagnosis=8.8 Fitness=9.0 HuntersBow=8.0 HealingHalo=8.0 Divinity=8.0 Wish=8.0
Start status: Overall CL: 8.4, Total Orbs: 2384
Fitness raised to CL 10.0 (Overall CL: 8.6, Total Orbs: 2474)
Diagnosis raised to CL 9.0 (Overall CL: 8.6, Total Orbs: 2490)
Diagnosis raised to CL 10.0 (Overall CL: 8.8, Total Orbs: 2580)
Mantis raised to CL 9.0 (Overall CL: 9.0, Total Orbs: 2660)
Mantis raised to CL 10.0 (Overall CL: 9.2, Total Orbs: 2750)
Bump raised to CL 9.0 (Overall CL: 9.3, Total Orbs: 2830)
Bump raised to CL 10.0 (Overall CL: 9.4, Total Orbs: 2920)
HuntersBow raised to CL 9.0 (Overall CL: 9.6, Total Orbs: 3000)
HuntersBow raised to CL 10.0 (Overall CL: 9.7, Total Orbs: 3090)
HealingHalo raised to CL 9.0 (Overall CL: 9.8, Total Orbs: 3170)
HealingHalo raised to CL 10.0 (Overall CL: 9.8, Total Orbs: 3260)
Divinity raised to CL 9.0 (Overall CL: 9.9, Total Orbs: 3340)
Divinity raised to CL 10.0 (Overall CL: 9.9, Total Orbs: 3430)
Wish raised to CL 9.0 (Overall CL: 10.0, Total Orbs: 3510)
Wish raised to CL 10.0 (Overall CL: 10.0, Total Orbs: 3600)



Now, the truth of the matter is that I simply gave it the rings I was wearing in the order I was wearing them, but perhaps I value some rings over others? Then I give it those rings in the order I value them:


/Users/ekraft/ekraft/gaia/zomg > java Planner Fitness=9.0 Bump=8.0 Mantis=8.0 Diagnosis=8.8 HuntersBow=8.0 Divinity=8.0 Wish=8.0 HealingHalo=8.0
Start status: Overall CL: 8.4, Total Orbs: 2384
Fitness raised to CL 10.0 (Overall CL: 8.6, Total Orbs: 2474)
Diagnosis raised to CL 9.0 (Overall CL: 8.6, Total Orbs: 2490)
Diagnosis raised to CL 10.0 (Overall CL: 8.8, Total Orbs: 2580)
Bump raised to CL 9.0 (Overall CL: 9.0, Total Orbs: 2660)
Bump raised to CL 10.0 (Overall CL: 9.2, Total Orbs: 2750)
Mantis raised to CL 9.0 (Overall CL: 9.3, Total Orbs: 2830)
Mantis raised to CL 10.0 (Overall CL: 9.4, Total Orbs: 2920)
HuntersBow raised to CL 9.0 (Overall CL: 9.6, Total Orbs: 3000)
HuntersBow raised to CL 10.0 (Overall CL: 9.7, Total Orbs: 3090)
Divinity raised to CL 9.0 (Overall CL: 9.8, Total Orbs: 3170)
Divinity raised to CL 10.0 (Overall CL: 9.8, Total Orbs: 3260)
Wish raised to CL 9.0 (Overall CL: 9.9, Total Orbs: 3340)
Wish raised to CL 10.0 (Overall CL: 9.9, Total Orbs: 3430)
HealingHalo raised to CL 9.0 (Overall CL: 10.0, Total Orbs: 3510)
HealingHalo raised to CL 10.0 (Overall CL: 10.0, Total Orbs: 3600)






The code
These are the four classes I made for this little project:

Fraction.java - Used for exact fraction information
Ring.java - Represents a ring
Rings.java - Represents the rings you're wearing / using
Planner.java - Plans a level-up strategy for your rings



You'll need all four to run the planner, but only the first three to run the overall CL calculator. 3nodding




Fraction.java
import java.util.*;


public class Fraction
implements Comparable {

protected long quotient;
protected long divisor;


public Fraction(long integer) {

quotient = integer;
divisor = 1;
}


public Fraction(long top,
long bottom) {

if (bottom == 0) {
throw new IllegalArgumentException("Division by zero")
}

if (bottom < 0) {
top = -top;
bottom = -bottom;
}

quotient = top;
divisor = bottom;
}


public Fraction add(Fraction toAdd) {

long newTop = quotient * toAdd.divisor + toAdd.quotient * divisor;
long newBottom = divisor * toAdd.divisor;

Fraction result = new Fraction(newTop, newBottom)
return result.reduce()
}


public Fraction subtract(Fraction toSub) {

long newTop = quotient * toSub.divisor - toSub.quotient * divisor;
long newBottom = divisor * toSub.divisor;

Fraction result = new Fraction(newTop, newBottom)
return result.reduce()
}


public Fraction multiply(Fraction toMult) {

long newTop = quotient * toMult.quotient;
long newBottom = divisor * toMult.divisor;

Fraction result = new Fraction(newTop, newBottom)
return result.reduce()
}


public Fraction divide(Fraction toDiv) {

long newTop = quotient * toDiv.divisor;
long newBottom = divisor * toDiv.quotient;

Fraction result = new Fraction(newTop, newBottom)
return result.reduce()
}


public Fraction reduce() {

List qFactors = factor(quotient)
List dFactors = factor(divisor)

Iterator qIterator = qFactors.iterator()
Iterator dIterator = dFactors.iterator()
long dCurrent = dIterator.next()

while (qIterator.hasNext()) {
long qCurrent = qIterator.next()

while (dCurrent < qCurrent) {
if (dIterator.hasNext() == false) {
return this;
}
dCurrent = dIterator.next()
}

if (qCurrent < dCurrent) {
continue;
}

quotient /= qCurrent;
divisor /= dCurrent;
if (dIterator.hasNext() == false) {
return this;
}
dCurrent = dIterator.next()
}

return this;
}


private static List factor(long value) {

List results = new LinkedList()
factor(value, results)
return results;
}


private static void factor(long value,
List factors) {

long current = 2;
while (true) {
if (current * current > value) {
factors.add(value)
return;
}

if (value % current == 0) {
factors.add(current)
factor(value / current, factors)
return;
}

current++;
}
}


public boolean equals(Object object) {

if ((object == null) ||
(object instanceof Fraction) == false) {
return false;
}

Fraction fraction = (Fraction) object;
return (value() == fraction.value())
}


public double value() {

return (double)quotient / (double)divisor;
}


public String toString() {

return quotient + "/" + divisor;
}


public int compareTo(Fraction fraction) {

return (int)(quotient * fraction.divisor - fraction.quotient * divisor)
}
}



Ring.java
import java.util.*;
import java.util.regex.*;


public class Ring
implements Comparable {

private static final Pattern RING_LINE = Pattern.compile("^([A-Za-z]+)=((\\d+)(\\.(\\d))?)$")
private static final List RING_NAMES = new ArrayList()
private static int RING_NAME_LENGTH = 0;


private static void addRingName(String name) {

RING_NAMES.add(name)
if (name.length() > RING_NAME_LENGTH) {
RING_NAME_LENGTH = name.length()
}
}


private String name;
private Fraction cl;


public Ring(String line) {

Matcher matcher = RING_LINE.matcher(line)
if (matcher.find() == false) {
throw new IllegalArgumentException(line + " not of the format =")
}

this.name = matcher.group(1)
String clMajor = matcher.group(3)
int cl = 0;
try {
cl = 10 * Integer.parseInt(clMajor)
} catch(NumberFormatException e) {
throw new IllegalArgumentException(line + " not of the format =")
}

String clMinor = matcher.group(5)
if (clMinor != null) {
try {
cl += Integer.parseInt(clMinor)
} catch(NumberFormatException e) {
throw new IllegalArgumentException(line + " not of the format =")
}
}

this.cl = new Fraction(cl, 10)
addRingName(this.name)
}


public Ring(String name,
Fraction cl) {

this.name = name;
this.cl = cl;
addRingName(this.name)
}


public String name() {

return name;
}


public String displayName() {

String display = name;
while (display.length() < RING_NAME_LENGTH) {
display += " ";
}
return display;
}


public Fraction cl() {

return cl;
}


public void setCl(int newValue) {

this.cl = new Fraction(newValue, 1)
}


public int orbs() {

int major = (int) Math.floor(cl.value())
int minor = (int) ((cl.value() - major) * 10)

return minor * major + 5 * major * (major - 1)
}


public int compareTo(Ring ring) {

int fractionCompare = cl.compareTo(ring.cl())
if (fractionCompare == 0) {
int myIndex = RING_NAMES.indexOf(name)
int theirIndex = RING_NAMES.indexOf(ring.name())
return theirIndex - myIndex;
}
return fractionCompare;
}
}



Rings.java
import java.util.*;
import java.util.regex.*;


public class Rings {


private TreeSet rings = new TreeSet()


public void addRing(String line) {

if (rings.size() == 8) {
throw new IllegalArgumentException("Too many rings ; only 8 allowed")
}

rings.add(new Ring(line))
}


public Fraction overallCl() {

Fraction value = new Fraction(0, 1)
long multiplier = 1;
for (int i = 0; i < 8 - rings.size() i++) {
value = value.add(new Fraction(multiplier++, 1))
}

for (Ring ring : rings) {
Fraction multi = new Fraction(multiplier++, 1)
multi = multi.multiply(ring.cl())
value = value.add(multi)
}

return value.divide(new Fraction(36, 1))
}


public double overallClDouble() {

double value = overallCl().value() * 10;
return Math.round(value) / 10.0;
}


public Map getRingWeights() {

Map toReturn = new HashMap()
int multiplier = 9 - rings.size()
for (Ring ring : rings) {
toReturn.put(ring, multiplier++)
}
return toReturn;
}


public Ring lowest() {

return rings.first()
}

public void reorder() {

TreeSet newRings = new TreeSet()
newRings.addAll(rings)
rings = newRings;
}


public int totalOrbs() {

int orbs = 0;
for (Ring ring : rings) {
orbs += ring.orbs()
}
return orbs;
}


public void addRings(Collection addTo) {

addTo.addAll(rings)
}


public int size() {

return rings.size()
}


public static void main(String[] args) {

Rings rings = new Rings()
for (String arg : args) {
if (arg.indexOf("=") == -1) {
char random = (char)('a' + rings.size())
arg = random + "=" + arg;
}
rings.addRing(arg)
}

System.out.println("Overall CL: " + rings.overallClDouble())
System.out.println(" (Exact value: " + rings.overallCl() + ")")
System.out.println("Total orbs: " + rings.totalOrbs())
}
}



Planner.java
import java.util.*;


public class Planner {


public static void main(String[] args) {

Rings rings = new Rings()
for (String arg : args) {
if (arg.indexOf("=") > -1) {
rings.addRing(arg)
}
}

plan(rings)
}


public static void plan(Rings rings) {

System.out.println("Start status: " + status(rings))

while (ringsToLevel(rings)) {
Ring ring = findRingToLevel(rings)

double cl = levelRing(ring)
String level = "" + cl;
if (cl < 10.0) {
level = " " + level;
}

System.out.println(ring.displayName() + " raised to CL " + level +
" (" + status(rings) + ")")
}
}


public static String status(Rings rings) {

rings.reorder()

double overallCl = rings.overallClDouble()
String overall = "" + overallCl;
if (overallCl < 10.0) {
overall = " " + overall;
}

String totalOrbs = "" + rings.totalOrbs()
while (totalOrbs.length() < 4) {
totalOrbs = " " + totalOrbs;
}

return "Overall CL: " + overall +
", Total Orbs: " + totalOrbs;
}


public static boolean ringsToLevel(Rings rings) {

return rings.lowest().cl().value() < 10.0;
}


public static Ring findRingToLevel(Rings rings) {

TreeSet order = new TreeSet(new CandidatePicker(rings))
rings.addRings(order)

Ring chosenOne = order.last()
while (chosenOne.cl().value() == 10.0) {
order.remove(chosenOne)
chosenOne = order.last()
}
return chosenOne;
}


public static double levelRing(Ring ring) {

int newCl = (int) Math.floor(ring.cl().value() + 1)
ring.setCl(newCl)
return newCl;
}


public static class CandidatePicker
implements Comparator {

private Map weights;


public CandidatePicker(Rings rings) {

this.weights = rings.getRingWeights()
}


public boolean equals(Object object) {
return (object instanceof CandidatePicker)
}


public int compare(Ring ring1,
Ring ring2) {

long orbs1 = (long) Math.floor(ring1.cl().value())
long orbs2 = (long) Math.floor(ring2.cl().value())

long weight1 = weights.get(ring1)
long weight2 = weights.get(ring2)

Fraction fraction1 = new Fraction(weight1, orbs1)
Fraction fraction2 = new Fraction(weight2, orbs2)

if (fraction1.equals(fraction2) == false) {
return fraction1.compareTo(fraction2)
}

return ring1.compareTo(ring2)
}
}
}
 
PostPosted: Sat Nov 22, 2008 7:24 pm
burning_eyes  

Goddess Lia


lazy bonz

PostPosted: Sat Nov 22, 2008 7:31 pm
OMG!!! Nadian, you are the GOD of . . . something.

I understood the basic idea of the earlier posts, but this program is too amazing.
And you whipped this out in a couple hours. rofl
I hope you post this in the zOMG forums somewhere.  
PostPosted: Sat Nov 22, 2008 9:27 pm
Maybe I'll create a GUI interface for it or something. Maybe I ought to experiment with creating a Java applet to run in a browser...


FYI, if you have 8 rings, all CL 1.0, here's how to level them to increase your overall CL as fast as you can:


/Users/ekraft/ekraft/gaia/zomg > java Planner A=1.0 B=1.0 C=1.0 D=1.0 E=1.0 F=1.0 G=1.0 H=1.0
Start status: Overall CL: 1.0, Total Orbs: 0
A raised to CL 2.0 (Overall CL: 1.2, Total Orbs: 10)
B raised to CL 2.0 (Overall CL: 1.4, Total Orbs: 20)
C raised to CL 2.0 (Overall CL: 1.6, Total Orbs: 30)
D raised to CL 2.0 (Overall CL: 1.7, Total Orbs: 40)
A raised to CL 3.0 (Overall CL: 1.9, Total Orbs: 60)
E raised to CL 2.0 (Overall CL: 2.1, Total Orbs: 70)
B raised to CL 3.0 (Overall CL: 2.3, Total Orbs: 90)
C raised to CL 3.0 (Overall CL: 2.4, Total Orbs: 110)
F raised to CL 2.0 (Overall CL: 2.5, Total Orbs: 120)
A raised to CL 4.0 (Overall CL: 2.7, Total Orbs: 150)
D raised to CL 3.0 (Overall CL: 2.9, Total Orbs: 170)
B raised to CL 4.0 (Overall CL: 3.1, Total Orbs: 200)
A raised to CL 5.0 (Overall CL: 3.3, Total Orbs: 240)
C raised to CL 4.0 (Overall CL: 3.4, Total Orbs: 270)
E raised to CL 3.0 (Overall CL: 3.6, Total Orbs: 290)
G raised to CL 2.0 (Overall CL: 3.6, Total Orbs: 300)
B raised to CL 5.0 (Overall CL: 3.8, Total Orbs: 340)
D raised to CL 4.0 (Overall CL: 3.9, Total Orbs: 370)
A raised to CL 6.0 (Overall CL: 4.2, Total Orbs: 420)
C raised to CL 5.0 (Overall CL: 4.3, Total Orbs: 460)
F raised to CL 3.0 (Overall CL: 4.4, Total Orbs: 480)
B raised to CL 6.0 (Overall CL: 4.6, Total Orbs: 530)
A raised to CL 7.0 (Overall CL: 4.8, Total Orbs: 590)
E raised to CL 4.0 (Overall CL: 4.9, Total Orbs: 620)
D raised to CL 5.0 (Overall CL: 5.1, Total Orbs: 660)
C raised to CL 6.0 (Overall CL: 5.3, Total Orbs: 710)
B raised to CL 7.0 (Overall CL: 5.4, Total Orbs: 770)
A raised to CL 8.0 (Overall CL: 5.7, Total Orbs: 840)
A raised to CL 9.0 (Overall CL: 5.9, Total Orbs: 920)
B raised to CL 8.0 (Overall CL: 6.1, Total Orbs: 990)
C raised to CL 7.0 (Overall CL: 6.3, Total Orbs: 1050)
D raised to CL 6.0 (Overall CL: 6.4, Total Orbs: 1100)
E raised to CL 5.0 (Overall CL: 6.5, Total Orbs: 1140)
F raised to CL 4.0 (Overall CL: 6.6, Total Orbs: 1170)
G raised to CL 3.0 (Overall CL: 6.6, Total Orbs: 1190)
H raised to CL 2.0 (Overall CL: 6.7, Total Orbs: 1200)
A raised to CL 10.0 (Overall CL: 6.9, Total Orbs: 1290)
B raised to CL 9.0 (Overall CL: 7.1, Total Orbs: 1370)
C raised to CL 8.0 (Overall CL: 7.3, Total Orbs: 1440)
D raised to CL 7.0 (Overall CL: 7.4, Total Orbs: 1500)
E raised to CL 6.0 (Overall CL: 7.5, Total Orbs: 1550)
B raised to CL 10.0 (Overall CL: 7.7, Total Orbs: 1640)
C raised to CL 9.0 (Overall CL: 7.9, Total Orbs: 1720)
F raised to CL 5.0 (Overall CL: 7.9, Total Orbs: 1760)
D raised to CL 8.0 (Overall CL: 8.1, Total Orbs: 1830)
C raised to CL 10.0 (Overall CL: 8.3, Total Orbs: 1920)
E raised to CL 7.0 (Overall CL: 8.4, Total Orbs: 1980)
G raised to CL 4.0 (Overall CL: 8.4, Total Orbs: 2010)
D raised to CL 9.0 (Overall CL: 8.6, Total Orbs: 2090)
F raised to CL 6.0 (Overall CL: 8.6, Total Orbs: 2140)
E raised to CL 8.0 (Overall CL: 8.8, Total Orbs: 2210)
D raised to CL 10.0 (Overall CL: 8.9, Total Orbs: 2300)
E raised to CL 9.0 (Overall CL: 9.0, Total Orbs: 2380)
F raised to CL 7.0 (Overall CL: 9.1, Total Orbs: 2440)
G raised to CL 5.0 (Overall CL: 9.1, Total Orbs: 2480)
H raised to CL 3.0 (Overall CL: 9.2, Total Orbs: 2500)
E raised to CL 10.0 (Overall CL: 9.3, Total Orbs: 2590)
F raised to CL 8.0 (Overall CL: 9.4, Total Orbs: 2660)
G raised to CL 6.0 (Overall CL: 9.4, Total Orbs: 2710)
F raised to CL 9.0 (Overall CL: 9.5, Total Orbs: 2790)
F raised to CL 10.0 (Overall CL: 9.6, Total Orbs: 2880)
G raised to CL 7.0 (Overall CL: 9.6, Total Orbs: 2940)
H raised to CL 4.0 (Overall CL: 9.7, Total Orbs: 2970)
G raised to CL 8.0 (Overall CL: 9.7, Total Orbs: 3040)
G raised to CL 9.0 (Overall CL: 9.8, Total Orbs: 3120)
H raised to CL 5.0 (Overall CL: 9.8, Total Orbs: 3160)
G raised to CL 10.0 (Overall CL: 9.9, Total Orbs: 3250)
H raised to CL 6.0 (Overall CL: 9.9, Total Orbs: 3300)
H raised to CL 7.0 (Overall CL: 9.9, Total Orbs: 3360)
H raised to CL 8.0 (Overall CL: 9.9, Total Orbs: 3430)
H raised to CL 9.0 (Overall CL: 10.0, Total Orbs: 3510)
H raised to CL 10.0 (Overall CL: 10.0, Total Orbs: 3600)
 

Nadian
Crew


Skelanimic Polka-Dot

PostPosted: Sat Nov 22, 2008 9:35 pm
User Image

I myself, lacking in the ability to solve math problems, am never going to attempt to calculate overall CL.  
PostPosted: Tue May 12, 2009 8:12 pm
my brain died this moment xp  

RiziN-ergeez


Abundant Void

5,750 Points
  • First step to fame 200
  • Dressed Up 200
  • Nudist Colony 200
PostPosted: Tue Jun 09, 2009 10:43 pm
Very well done on the math. This helps quite a bit as well. Glad I actually understood it.  
PostPosted: Mon Jul 13, 2009 11:45 pm
thank you. i never really understood how they calculated it.
it's actually pretty simple if you think about it, although it is a lot to read. just don't over complicate it and you should get it easily.
now i can increase my cl easier!
yay!  

killercloud94

Reply
"TIZ" This... is... zOMG!!

Goto Page: [] [<] 1 2
 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum