- Joined
- Aug 16, 2006
- Messages
- 1,251
- Reaction score
- 199
To propperly test my function to calculate the exp to level of pokemon using the pokenet database (also known as pokemonium or poke ares etc.)
Currently this is the function (in vb.net)
I can really only test this code using pokemon generated by the game because of the way they gain exp etc, so when i change the expType in the database i think its breaking it, from what i can tell though the following ones arent working and i just want to be able to test them against a more complete database.
Im currently using a database that was posted in a different thread and it happened to have a few users with pokemon but most of the pokemon are Parabolic...
Thanks.
I converted this from the original source code found in BattleMechanics.java
EDIT
Fixed the function, it now looks like this and is 100% working.
now i can calculate the pokemons level! yay
Currently this is the function (in vb.net)
PHP:
Public Function CalculateLevel(expType As String, exp As String)
Dim Result As Double = 0
If expType = "MEDIUM" Then
Dim i As Double = 1
For i = i To 100
i = i + 1
If i < 100 And exp >= i * i And exp < (i + 1) * (i + 1) * (i + 1) Then
Result = i
ElseIf i = 100 And exp >= i * i * i Then
Result = 100
ElseIf exp >= 1000000 Then
Result = 100
End If
Next
ElseIf expType = "ERRATIC" Then
Dim i As Double = 1
For i = i To 101
i = i + 1
If i < 50 Then
If exp >= i * i * i * ((100 - i) / 50) And exp < (i + 1) * (i + 1) * (i + 1) * ((100 - (i + 1)) / 50) Then
Result = i
End If
ElseIf i = 50 Then
Result = i
ElseIf i >= 51 And i < 68 Then
If exp >= i * i * i * ((150 - i) / 50) And exp < (i + 1) * (i + 1) * (i + 1) * ((150 - (i + 1)) / 50) Then
Result = i
End If
ElseIf i = 68 Then
Result = i
ElseIf i >= 69 And i < 98 Then
Dim temp As Double = exp
Dim funt As Double = i * 3 / 100
Dim funt1 = (i + 1) * 3 / 100
If funt = 1 Then
funt = 0.008
ElseIf funt = 2 Then
funt = 0.014
If funt1 = 1 Then
funt1 = 0.008
ElseIf funt1 = 2 Then
funt1 = 0.014
If temp >= i * i * i * (1.274 - 1 / 50 * (i / 3) - funt) And temp < (i + 1) * (i + 1) * (i + 1) * (1.274 - 1 / 50 * ((i + 1) / 3) - funt1) Then
Result = i
End If
End If
End If
ElseIf i = 98 Then
Result = i
ElseIf i = 99 Then
If exp >= i * i * i * ((160 - i) / 50) And exp < (i + 1) * (i + 1) * (i + 1) * ((160 - (i + 1)) / 50) Then
Result = 1
End If
ElseIf i = 100 Then
If exp > i * i * i * ((160 - i) / 50) Then
Result = i
End If
ElseIf exp >= 600000 Then
Result = 100
End If
Next
ElseIf expType = "FLUCTUATING" Then
Dim i As Double = 101
For i = i To 36
i = i - 1
If exp < i * i * i * ((32 + i / 2) / 50) Then
Result = i - 1
End If
Next
For i = 36 To 15
If exp < i * i * i * ((32 + i / 2) / 50) Then
Result = i - 1
End If
Next
For i = 15 To 1
i = i - 1
Dim reqExp As Double = i * i * i * ((24 + (i + 1) / 3) / 50)
If exp < reqExp Then
Result = i - 1
End If
Next
If exp >= 1640000 Then
Result = 100
End If
ElseIf expType = "PARABOLIC" Then
Dim i As Double = 101
For i = i To 1
i = i - 1
If exp < 6 * (i * i * i) / 5 - 15 * (i * i) + 100 * i - 140 Then
Result = i - 1
ElseIf exp >= 1059860 Then
Result = 100
End If
Next
ElseIf expType = "FAST" Then
Dim i As Double = 101
For i = i To 1
i = i - 1
If exp < 4 * (i * i * i) / 5 Then
Result = i - 1
ElseIf exp >= 800000 Then
Result = 100
End If
Next
ElseIf expType = "SLOW" Then
Dim i As Double = 101
For i = i To 1
i = i - 1
If exp < 5 * (i * i * i) / 4 Then
Result = i - 1
ElseIf exp >= 1250000 Then
Result = 100
End If
Next
End If
Return Result
End Function
I can really only test this code using pokemon generated by the game because of the way they gain exp etc, so when i change the expType in the database i think its breaking it, from what i can tell though the following ones arent working and i just want to be able to test them against a more complete database.
Code:
Parabolic
Erratic
Fast
Slow
Im currently using a database that was posted in a different thread and it happened to have a few users with pokemon but most of the pokemon are Parabolic...
Thanks.
I converted this from the original source code found in BattleMechanics.java
PHP:
public int calculateLevel(Pokemon a) {
double result = 0;
switch(a.getExpType())
{
case MEDIUM:
{
for(double i = 1; i <= 100; i++)
if(i < 100 && a.getExp() >= i * i * i && a.getExp() < (i + 1) * (i + 1) * (i + 1))
{
result = i;
break;
}
else if(i == 100 && a.getExp() >= i * i * i)
{
result = 100;
break;
}
else if(a.getExp() >= 1000000)
{
result = 100;
a.setExp(1000000);
break;
}
}
break;
case ERRATIC:
{
for(double i = 1; i < 101; i++)
if(i < 50)
{
if(a.getExp() >= i * i * i * ((100 - i) / 50) && a.getExp() < (i + 1) * (i + 1) * (i + 1) * ((100 - (i + 1)) / 50))
{
result = i;
break;
}
}
else if(i == 50)
result = i;
else if(i >= 51 && i < 68)
{
if(a.getExp() >= i * i * i * ((150 - i) / 50) && a.getExp() < (i + 1) * (i + 1) * (i + 1) * ((150 - (i + 1)) / 50))
{
result = i;
break;
}
}
else if(i == 68)
result = i;
else if(i >= 69 && i < 98)
{
double temp = a.getExp();
double funt = i % 3;
double funt1 = (i + 1) % 3;
if(funt == 1)
funt = 0.008;
else if(funt == 2)
funt = 0.014;
if(funt1 == 1)
funt1 = 0.008;
else if(funt1 == 2)
funt1 = 0.014;
if(temp >= i * i * i * (1.274 - 1 / 50 * (i / 3) - funt) && temp < (i + 1) * (i + 1) * (i + 1) * (1.274 - 1 / 50 * ((i + 1) / 3) - funt1))
{
result = i;
break;
}
}
else if(i == 98)
result = i;
else if(i == 99)
{
if(a.getExp() >= i * i * i * ((160 - i) / 50) && a.getExp() < (i + 1) * (i + 1) * (i + 1) * ((160 - (i + 1)) / 50))
{
result = i;
break;
}
}
else if(i == 100)
{
if(a.getExp() >= i * i * i * ((160 - i) / 50))
{
result = i;
break;
}
}
else if(a.getExp() >= 600000)
{
result = 100;
a.setExp(600000);
break;
}
}
break;
case FLUCTUATING:
{
for(double i = 101; i > 36; i--)
if(a.getExp() < i * i * i * ((32 + i / 2) / 50))
result = i - 1;
for(double i = 36; i > 15; i--)
{
System.out.println(i);
if(a.getExp() < i * i * i * ((14 + i) / 50))
result = i - 1;
}
for(double i = 15; i > 1; i--)
{
double reqExp = i * i * i * ((24 + (i + 1) / 3) / 50);
if(a.getExp() < reqExp)
result = i - 1;
}
if(a.getExp() >= 1640000)
{
result = 100;
a.setExp(1640000);
break;
}
}
break;
case PARABOLIC:
{
for(double i = 101; i > 1; i--)
if(a.getExp() < 6 * (i * i * i) / 5 - 15 * (i * i) + 100 * i - 140)
result = i - 1;
else if(a.getExp() >= 1059860)
{
result = 100;
a.setExp(1059860);
break;
}
}
break;
case FAST:
{
for(double i = 101; i > 1; i--)
if(a.getExp() < 4 * (i * i * i) / 5)
result = i - 1;
else if(a.getExp() >= 800000)
{
result = 100;
a.setExp(800000);
break;
}
}
break;
case SLOW:
{
for(double i = 101; i > 1; i--)
if(a.getExp() < 5 * (i * i * i) / 4)
result = i - 1;
else if(a.getExp() >= 1250000)
{
result = 100;
a.setExp(1250000);
break;
}
}
}
return (int) result;
}
EDIT
Fixed the function, it now looks like this and is 100% working.
Code:
Public Function CalculateLevel(expType As String, exp As String) Dim Result As Double = 0
If expType = "MEDIUM" Then
For i As Double = 1 To 100
If i < 100 AndAlso exp >= i * i * i AndAlso exp < (i + 1) * (i + 1) * (i + 1) Then
Result = i
Exit For
ElseIf i = 100 AndAlso exp >= i * i * i Then
Result = 100
Exit For
ElseIf exp >= 1000000 Then
Result = 100
Exit For
End If
Next i
ElseIf expType = "ERRATIC" Then
For i As Double = 1 To 100
If i < 50 Then
If exp >= i * i * i * ((100 - i) / 50) AndAlso exp < (i + 1) * (i + 1) * (i + 1) * ((100 - (i + 1)) / 50) Then
Result = i
Exit For
End If
ElseIf i = 50 Then
Result = i
ElseIf i >= 51 AndAlso i < 68 Then
If exp >= i * i * i * ((150 - i) / 50) AndAlso exp < (i + 1) * (i + 1) * (i + 1) * ((150 - (i + 1)) / 50) Then
Result = i
Exit For
End If
ElseIf i = 68 Then
Result = i
ElseIf i >= 69 AndAlso i < 98 Then
Dim temp As Double = exp
Dim funt As Double = i Mod 3
Dim funt1 As Double = (i + 1) Mod 3
If funt = 1 Then
funt = 0.008
ElseIf funt = 2 Then
funt = 0.014
End If
If funt1 = 1 Then
funt1 = 0.008
ElseIf funt1 = 2 Then
funt1 = 0.014
End If
If temp >= i * i * i * (1.274 - 1 / 50 * (i / 3) - funt) AndAlso temp < (i + 1) * (i + 1) * (i + 1) * (1.274 - 1 / 50 * ((i + 1) / 3) - funt1) Then
Result = i
Exit For
End If
ElseIf i = 98 Then
Result = i
ElseIf i = 99 Then
If exp >= i * i * i * ((160 - i) / 50) AndAlso exp < (i + 1) * (i + 1) * (i + 1) * ((160 - (i + 1)) / 50) Then
Result = i
Exit For
End If
ElseIf i = 100 Then
If exp >= i * i * i * ((160 - i) / 50) Then
Result = i
Exit For
End If
ElseIf exp >= 600000 Then
Result = 100
Exit For
End If
Next i
ElseIf expType = "FLUCTUATING" Then
For i As Double = 101 To 37 Step -1
If exp < i * i * i * ((32 + i / 2) / 50) Then
Result = i - 1
End If
Next i
For i As Double = 36 To 16 Step -1
If exp < i * i * i * ((14 + i) / 50) Then
Result = i - 1
End If
Next i
For i As Double = 15 To 2 Step -1
Dim reqExp As Double = i * i * i * ((24 + (i + 1) / 3) / 50)
If exp < reqExp Then
Result = i - 1
End If
Next i
If exp >= 1640000 Then
Result = 100
End If
ElseIf expType = "PARABOLIC" Then
For i As Double = 101 To 2 Step -1
If exp < 6 * (i * i * i) / 5 - 15 * (i * i) + 100 * i - 140 Then
Result = i - 1
ElseIf exp >= 1059860 Then
Result = 100
Exit For
End If
Next i
ElseIf expType = "FAST" Then
For i As Double = 101 To 2 Step -1
If exp < 4 * (i * i * i) / 5 Then
Result = i - 1
ElseIf exp >= 800000 Then
Result = 100
Exit For
End If
Next i
ElseIf expType = "SLOW" Then
For i As Double = 101 To 2 Step -1
If exp < 5 * (i * i * i) / 4 Then
Result = i - 1
ElseIf exp >= 1250000 Then
Result = 100
Exit For
End If
Next i
End If
Return (Math.Truncate(Result))
End Function
now i can calculate the pokemons level! yay
Attachments
You must be registered for see attachments list
Last edited: