http://robowiki.net/w/index.php?title=Talk:CalculatingScore/ScoreWithRamming&feed=atom&action=history
Talk:CalculatingScore/ScoreWithRamming - Revision history
2024-03-29T12:43:43Z
Revision history for this page on the wiki
MediaWiki 1.34.1
http://robowiki.net/w/index.php?title=Talk:CalculatingScore/ScoreWithRamming&diff=16834&oldid=prev
RednaxelaBot: Using <syntaxhighlight>.
2010-07-01T08:33:13Z
<p>Using <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 08:33, 1 July 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</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 <package>;</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 <package>;</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 colspan="2" class="diff-lineno" id="mw-diff-left-l171" >Line 171:</td>
<td colspan="2" class="diff-lineno">Line 171:</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>}</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>
</table>
RednaxelaBot
http://robowiki.net/w/index.php?title=Talk:CalculatingScore/ScoreWithRamming&diff=2017&oldid=prev
Jab: Is it possible to calculate the score for an AdvancedRobot?
2008-03-29T14:22:59Z
<p>Is it possible to calculate the score for an AdvancedRobot?</p>
<p><b>New page</b></p><div><pre><br />
package <package>;<br />
<br />
import java.util.Iterator;<br />
import java.util.Vector;<br />
<br />
import robocode.*;<br />
<br />
/**<br />
* This is the Score class for duels.<br />
* <br />
* Instantiate this once on match start, and at the top of all the needed events<br />
* just pass them to the instance. Call printScore at any time to print the<br />
* scores to the console. Call getScore(id) at any time to get the score of the<br />
* requested robot (0 = self, 1 = enemy).<br />
* <br />
* If you'd like to use this in your robot, feel free to, but give credit!<br />
* <br />
* @author Vuen (original)<br />
* @author Jab (contributor)<br />
*/<br />
public class Score {<br />
<br />
AdvancedRobot robot;<br />
<br />
public Score(AdvancedRobot robot) {<br />
this.robot = robot;<br />
}<br />
<br />
public double enemyEnergy;<br />
public double myEnergy;<br />
public String enemyName;<br />
<br />
public static double[] total = new double[2];<br />
<br />
public double[] survivalScore = new double[2];<br />
<br />
public double[] bulletDamageBonus = new double[2];<br />
public double[] bulletDamage = new double[2];<br />
<br />
public double[] ramDamageBonus = new double[2];<br />
public double[] ramDamage = new double[2];<br />
<br />
public void onScannedRobot(ScannedRobotEvent e) {<br />
myEnergy = robot.getEnergy();<br />
enemyEnergy = e.getEnergy();<br />
if (enemyName == null)<br />
enemyName = e.getName();<br />
}<br />
<br />
public void onBulletHit(BulletHitEvent e) {<br />
if (e.getEnergy() < 0.001) {<br />
System.out.println("Score.onBulletHit()");<br />
return;<br />
} //ignore if enemy dead<br />
bulletDamage[0] += robocode.Rules.getBulletDamage(e.getBullet()<br />
.getPower());<br />
}<br />
<br />
public void onHitByBullet(HitByBulletEvent e) {<br />
if (robocode.Rules.getBulletDamage(e.getPower()) > myEnergy) {<br />
System.out.println("Score.onHitByBullet()");<br />
return;<br />
} //ignore if self dead<br />
bulletDamage[1] += robocode.Rules.getBulletDamage(e.getBullet()<br />
.getPower());<br />
}<br />
<br />
public void onHitRobot(HitRobotEvent e) {<br />
ramDamage[e.isMyFault() ? 0 : 1] += robocode.Rules.ROBOT_HIT_DAMAGE;<br />
}<br />
<br />
<br />
public void onWin(WinEvent e) {<br />
<br />
Vector<Event> v = robot.getAllEvents();<br />
Iterator<Event> i = v.iterator();<br />
while (i.hasNext()) {<br />
Event event = i.next();<br />
System.out.println("Missed event: " + event.getClass());<br />
if (event instanceof BulletHitEvent)<br />
onBulletHit((BulletHitEvent) event);<br />
if (event instanceof HitByBulletEvent)<br />
onHitByBullet((HitByBulletEvent) event);<br />
if (event instanceof HitRobotEvent)<br />
onHitRobot((HitRobotEvent) event);<br />
}<br />
<br />
survivalScore[0] = 60;<br />
if (v.size() > 0)<br />
if (v.lastElement() instanceof BulletHitEvent)<br />
bulletDamageBonus[0] = (bulletDamage[0] + ramDamage[0]) * .2;<br />
else if (v.lastElement() instanceof HitRobotEvent)<br />
ramDamageBonus[0] = (bulletDamage[0] + ramDamage[0]) * .3;<br />
ramDamage[0] *= 2;<br />
ramDamage[1] *= 2;<br />
<br />
total[0] += survivalScore[0] + bulletDamageBonus[0] + bulletDamage[0]<br />
+ ramDamageBonus[0] + ramDamage[0];<br />
total[1] += survivalScore[1] + bulletDamageBonus[1] + bulletDamage[1]<br />
+ ramDamageBonus[1] + ramDamage[1];<br />
this.printScore();<br />
}<br />
<br />
<br />
public void onDeath(DeathEvent e) {<br />
<br />
Vector<Event> v = robot.getAllEvents();<br />
Iterator<Event> i = v.iterator();<br />
while (i.hasNext()) {<br />
Event event = i.next();<br />
System.out.println("Missed event: " + event.getClass());<br />
if (event instanceof BulletHitEvent)<br />
onBulletHit((BulletHitEvent) event);<br />
if (event instanceof HitByBulletEvent)<br />
onHitByBullet((HitByBulletEvent) event);<br />
if (event instanceof HitRobotEvent)<br />
onHitRobot((HitRobotEvent) event);<br />
}<br />
<br />
survivalScore[1] = 60;<br />
if (v.size() > 0)<br />
if (v.lastElement() instanceof BulletHitEvent)<br />
bulletDamageBonus[1] = (bulletDamage[1] + ramDamage[1]) * .2;<br />
else if (v.lastElement() instanceof HitRobotEvent)<br />
ramDamageBonus[1] = (bulletDamage[1] + ramDamage[1]) * .3;<br />
ramDamage[0] *= 2;<br />
ramDamage[1] *= 2;<br />
<br />
total[0] += survivalScore[0] + bulletDamageBonus[0] + bulletDamage[0]<br />
+ ramDamageBonus[0] + ramDamage[0];<br />
total[1] += survivalScore[1] + bulletDamageBonus[1] + bulletDamage[1]<br />
+ ramDamageBonus[1] + ramDamage[1];<br />
this.printScore();<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(total[id]);<br />
}<br />
<br />
/** prints the score-card to the console */<br />
public void printScore() {<br />
System.out.println("Total: " + Math.round(total[0]) + " "<br />
+ robot.getName());<br />
double totalMe = survivalScore[0] + bulletDamageBonus[0]<br />
+ bulletDamage[0] + ramDamageBonus[0] + ramDamage[0];<br />
System.out<br />
.println("Total Survival BulletDmg BulletBonus RamDmg*2 RamDmgBonus");<br />
System.out.println(Math.round(totalMe) + " "<br />
+ Math.round(survivalScore[0]) + " "<br />
+ Math.round(bulletDamage[0]) + " "<br />
+ Math.round(bulletDamageBonus[0]) + " "<br />
+ Math.round(ramDamage[0]) + " "<br />
+ Math.round(ramDamageBonus[0]));<br />
<br />
System.out.println();<br />
<br />
System.out.println("Total: " + Math.round(total[1]) + " " + enemyName);<br />
double totalEnemy = survivalScore[1] + bulletDamageBonus[1]<br />
+ bulletDamage[1] + ramDamageBonus[1] + ramDamage[1];<br />
System.out<br />
.println("Total Survival BulletDmg BulletBonus RamDmg*2 RamDmgBonus");<br />
System.out.println(Math.round(totalEnemy) + " "<br />
+ Math.round(survivalScore[1]) + " "<br />
+ Math.round(bulletDamage[1]) + " "<br />
+ Math.round(bulletDamageBonus[1]) + " "<br />
+ Math.round(ramDamage[1]) + " "<br />
+ Math.round(ramDamageBonus[1]));<br />
}<br />
<br />
}<br />
</pre></div>
Jab