<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://robowiki.net/w/index.php?action=history&amp;feed=atom&amp;title=Thread%3ATalk%3ACunobelin%2FDanger_function%2Freply_%288%29</id>
	<title>Thread:Talk:Cunobelin/Danger function/reply (8) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://robowiki.net/w/index.php?action=history&amp;feed=atom&amp;title=Thread%3ATalk%3ACunobelin%2FDanger_function%2Freply_%288%29"/>
	<link rel="alternate" type="text/html" href="http://robowiki.net/w/index.php?title=Thread:Talk:Cunobelin/Danger_function/reply_(8)&amp;action=history"/>
	<updated>2026-04-06T20:10:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>http://robowiki.net/w/index.php?title=Thread:Talk:Cunobelin/Danger_function/reply_(8)&amp;diff=31158&amp;oldid=prev</id>
		<title>Nz.jdc: Reply to Danger function</title>
		<link rel="alternate" type="text/html" href="http://robowiki.net/w/index.php?title=Thread:Talk:Cunobelin/Danger_function/reply_(8)&amp;diff=31158&amp;oldid=prev"/>
		<updated>2013-06-19T14:37:03Z</updated>

		<summary type="html">&lt;p&gt;Reply to &lt;a href=&quot;/wiki/Thread:Talk:Cunobelin/Danger_function/reply_(5)&quot; title=&quot;Thread:Talk:Cunobelin/Danger function/reply (5)&quot;&gt;Danger function&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The intention was to save codesize by being able to use the same wave and stats functions for both gun and surfing.&lt;br /&gt;
I have tried my algorithm in Cunobelin as proof of concept and remarkably (after fixing one div by zero bug I created) it worked and got 50% scores against the original.&lt;br /&gt;
&lt;br /&gt;
However it neither saved on codesize nor execution speed, so the idea is probably a no starter as without that change I would have too direct a copy of cunobelin's movement and skipped turns due to data volumes in the gun. Turns out modern processors do very fast FP and the implementation of Integer.bitCount() has too many steps.&lt;br /&gt;
&lt;br /&gt;
I have another idea about weighting which might work, but the performance problem will remain. I will eventually try it, probably along with culling old data to mitigate volume, but it is a lower priority now that my &amp;quot;good&amp;quot; idea turned out not to help.&lt;br /&gt;
&lt;br /&gt;
For your amusement here is the idea:&lt;br /&gt;
&lt;br /&gt;
Replace the EnemyWaveDC.scan array of 5 (actually 4, the other is a special case) doubles with a single integer where that segmentation data is encoded using individual bits as tally marks (i.e. 0b1 = 1, 0b11 = 2, 0b111 = 3 etc using int encoded = (1 &amp;lt;&amp;lt; value) - 1;). The values are then assembled with | and &amp;lt;&amp;lt;. Note that this is not the same as simple adding as the positional information (i.e. which segment the data belongs to) is retained, as it must be for the XOR below to work.&lt;br /&gt;
&lt;br /&gt;
The point of this is then the loop over those 4 doubles in the distance calculation in checkDanger is no longer required and the manhattan distance can be calculated with Integer.bitCount(surfWave.scan ^ scan);&lt;br /&gt;
&lt;br /&gt;
I had hoped that using integers rather than doubles and removing the loop would provide a speed increase, but unfortunately FP is very fast and bitCount does a lot (20?) operations, so no gain :(&lt;/div&gt;</summary>
		<author><name>Nz.jdc</name></author>
		
	</entry>
</feed>