http://robowiki.net/w/index.php?title=CalculatingScore&feed=atom&action=history
CalculatingScore - Revision history
2024-03-28T20:15:09Z
Revision history for this page on the wiki
MediaWiki 1.34.1
http://robowiki.net/w/index.php?title=CalculatingScore&diff=16725&oldid=prev
Rednaxela: Use syntaxhighlight
2010-07-01T06:03:43Z
<p>Use syntaxhighlight</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 06:03, 1 July 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l2" >Line 2:</td>
<td colspan="2" class="diff-lineno">Line 2:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>: '''[[/Archived Talk 20070913]]'''</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>: '''[[/Archived Talk 20070913]]'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><<del class="diffchange diffchange-inline">pre</del>></div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><<ins class="diffchange diffchange-inline">syntaxhighlight</ins>></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>package <yourpackage>;</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>package <yourpackage>;</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>import robocode.*;</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>import robocode.*;</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l134" >Line 134:</td>
<td colspan="2" class="diff-lineno">Line 134:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div></<del class="diffchange diffchange-inline">pre</del>></div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></<ins class="diffchange diffchange-inline">syntaxhighlight</ins>></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Code Snippets]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Code Snippets]]</div></td></tr>
</table>
Rednaxela
http://robowiki.net/w/index.php?title=CalculatingScore&diff=2011&oldid=prev
Jab: code snippets category
2008-03-29T13:53:34Z
<p>code snippets category</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 13:53, 29 March 2008</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l135" >Line 135:</td>
<td colspan="2" class="diff-lineno">Line 135:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:Code Snippets]]</ins></div></td></tr>
</table>
Jab
http://robowiki.net/w/index.php?title=CalculatingScore&diff=2010&oldid=prev
Jab: Migration: CalculatingScore by Vuen
2008-03-29T13:52:04Z
<p>Migration: CalculatingScore by Vuen</p>
<p><b>New page</b></p><div>; <nowiki>Sub-pages: </nowiki><br />
: '''[[/Archived Talk 20070913]]'''<br />
<br />
<pre><br />
package <yourpackage>;<br />
import robocode.*;<br />
import java.util.*;<br />
<br />
<br />
/**<br />
This is the Score class for duels. This code is<br />
basically what is included in Fractal and Cake to keep<br />
score.<br />
<br />
Instantiate this once on match start, and at the top<br />
of all the needed events just pass them to the instance.<br />
Call printScore at any time to print the scores to<br />
the console. Call getScore(id) at any time to get the<br />
score of the requested robot (0 = self, 1 = enemy).<br />
<br />
If you'd like to use this in your robot, feel free to,<br />
but give credit! -- Vuen<br />
*/<br />
public class Score {<br />
<br />
Robot robot;<br />
<br />
public Score(Robot robot) {<br />
this.robot = robot;<br />
}<br />
<br />
<br />
<br />
public double enemyEnergy;<br />
public double myEnergy;<br />
public String enemyName;<br />
<br />
public double[] bullet = new double[2];<br />
public double[] curbullet = new double[2];<br />
public double[] survival = new double[2];<br />
<br />
<br />
<br />
public void onScannedRobot(ScannedRobotEvent e) {<br />
myEnergy = robot.getEnergy();<br />
enemyEnergy = e.getEnergy();<br />
if (enemyName == null) enemyName = e.getName();<br />
}<br />
<br />
public void onBulletHit(BulletHitEvent e) {<br />
if (e.getEnergy() < 0.001) return; //ignore if enemy dead<br />
<br />
curbullet[0] += 4 * e.getBullet().getPower() + 2 * Math.max(e.getBullet().getPower() - 1, 0);<br />
}<br />
<br />
public void onHitByBullet(HitByBulletEvent e) {<br />
if (e.getPower() * 4 + Math.max(0, e.getPower() - 1) * 2 > myEnergy) return; //ignore if self dead<br />
//this works regardless of order of hitbybullet and scan<br />
<br />
curbullet[1] += 4 * e.getBullet().getPower() + 2 * Math.max(e.getBullet().getPower() - 1, 0);<br />
}<br />
<br />
public void onWin(WinEvent e) {<br />
survival[0] += 60;<br />
<br />
curbullet[0] += enemyEnergy;<br />
<br />
bullet[0] += curbullet[0] * 1.2;<br />
bullet[1] += curbullet[1];<br />
<br />
curbullet[0] = 0; curbullet[1] = 0;<br />
}<br />
<br />
public void onDeath(DeathEvent e) {<br />
survival[1] += 60;<br />
<br />
curbullet[1] += myEnergy;<br />
<br />
bullet[0] += curbullet[0];<br />
bullet[1] += curbullet[1] * 1.2;<br />
<br />
curbullet[0] = 0; curbullet[1] = 0;<br />
}<br />
<br />
<br />
<br />
/** returns the score of the requested robot: 0=self, 1=enemy */<br />
public int getScore(int id) {<br />
return (int)Math.round(bullet[id] + curbullet[id] + survival[id]);<br />
}<br />
<br />
/** prints the scorecard to the console */<br />
public void printScore() {<br />
if (enemyName == null) return;<br />
<br />
System.out.println(" ***********SCORECARD***********");<br />
System.out.print(" ");<br />
for (int i = 0; i < Math.max(robot.getName().length(), enemyName.length()); i++) System.out.print(" ");<br />
System.out.println(" Total Survival Bullet");<br />
<br />
String p0 = " " + robot.getName();<br />
String p1 = " " + enemyName;<br />
<br />
String pTemp = " " + Math.round(bullet[0] + survival[0] + curbullet[0]);<br />
for (int i = robot.getName().length(); i < Math.max(robot.getName().length(), enemyName.length()) + 7 - pTemp.length(); i++) p0 += " ";<br />
<br />
pTemp = (" " + Math.round(bullet[1] + survival[1] + curbullet[1]));<br />
for (int i = enemyName.length(); i < Math.max(robot.getName().length(), enemyName.length()) + 7 - pTemp.length(); i++) p1 += " ";<br />
<br />
p0 += Math.round(bullet[0] + survival[0] + curbullet[0]) + " ";<br />
p1 += Math.round(bullet[1] + survival[1] + curbullet[1]) + " ";<br />
pTemp = (" " + Math.round(survival[0]));<br />
for (int i = 0; i < 8 - pTemp.length(); i++) p0 += " ";<br />
pTemp = (" " + Math.round(survival[1]));<br />
for (int i = 0; i < 8 - pTemp.length(); i++) p1 += " ";<br />
<br />
p0 += Math.round(survival[0]) + " ";<br />
p1 += Math.round(survival[1]) + " ";<br />
pTemp = (" " + Math.round(bullet[0] + curbullet[0]));<br />
for (int i = 0; i < 6 - pTemp.length(); i++) p0 += " ";<br />
<br />
pTemp = (" " + Math.round(bullet[1] + curbullet[1]));<br />
for (int i = 0; i < 6 - pTemp.length(); i++) p1 += " ";<br />
<br />
p0 += Math.round(bullet[0] + curbullet[0]);<br />
p1 += Math.round(bullet[1] + curbullet[1]);<br />
<br />
if (bullet[0] + survival[0] + curbullet[0] >= bullet[1] + survival[1] + curbullet[1]) {<br />
System.out.println(p0); System.out.println(p1);<br />
} else {<br />
System.out.println(p1); System.out.println(p0);<br />
}<br />
}<br />
<br />
}<br />
</pre></div>
Jab