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)
Spoiler:
PHP Code:
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.
Spoiler:
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 Code:
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.
Spoiler:
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
System.out.println(i); if(a.getExp() < i * i * i * ((14 + i) / 50)) result = i - 1;
This is how the game calculates it, the i*i*i is how its done, and in my opinion thats the best way to do it, once you multiply i by itseleft it will change unless its 1, then u need to multiply it again, i see no easier way of doing this and unless you have an example you shouldnt post.
Your posts are not constructive they are just criticism. You're right i could have use enums but i didnt and in my opinion it doesnt really make a difference in performance on a tool this small. And quite bashing VB for christ sake, it can do everything C# can do and just because you dont like it doesnt mean you need to tell people it should be recoded in a different language.
If you think it could be done better, then do it yourself, make a toolbox with the functions i have, in a different language, and make it better than mine, dont just sit here and tell me my coding is crap, prove it.
Be constructive or dont reply.
18-09-14
The General
Re: Small request from the community.
In all honesty, the syntax in VB is hard to read. I prefer brackets over THEN. Also for-loops are horrible to read xD My opinion but nice you got that function working!
18-09-14
-DefaulT
Re: Small request from the community.
Well im done with this thread haha, the function was fixed and your comment was off topic, this whole conversation is off topic, @The General actuall backed up why he doesnt like vb etc, you just come up with nonsense, and keep trying to call it trash, you dont have to bash on things you dont understand, just explain why you dont like it not how you think its crap.
I've already requested this thread be closed, the problem was fixed and all thats going on now is just a war of coding languages with a close minded person.