[Home]Flood16CodeSnippets

Robo Home | Changes | Preferences | AllPages

Flood16, or FloodTest? in various incarnations was an experiment based on FloodMini that partially turned into most of the VG array in FloodHT 0.7. The idea is to store stats for every combination of a set of segmentations and to try to pick the best combination of segmentations to use to fire. Keep in mind that I never got this to work in general, as I couldn't find an effective way to select segmentations without the weakness of either my own lack of knowledge or the thrashing problems with VGs. Here's some relevant pieces of the algorithm:

Snippet 1: Creating the stats array

Keep in mind that the segmentations used here are from FloodMini 1.3, but each segmentation has one more bucket that basically means "not segmented on this parameter".

	// 2 wall, 3 latv, 3 acceleration, 10 distance, 31 guessfactors
	stats = new int[3][4][4][11][31];

Snippet 2: Inserting stats

With 4 segmentations, I have 16 stat buffers, so here I insert a hit into all 16 of them.

//the indexes are from 0 - (number of segments-1), segment is the bucket that hit.
public void addStat(int wall, int acc, int latv, int dist, int segment)
{
	//add the stat to each of the sixteen guns:
	for (int i=0; i<16; i++)
	{
		int tempdist = (i&1)*(dist+1);
		int templatv = ((i>>1)&1)*(latv+1);
		int tempacc = ((i>>2)&1)*(acc+1);
		int tempwall = ((i>>3)&1)*(wall+1);
		stats[tempwall][tempacc][templatv][tempdist][segment]++;
	}
}

Snippet 3: Getting the bearing from one of the guns

Now we need to figure out what direction to shoot for a specific VG. The comments which are from the original bot explain the gunID variable, which is a number from 0 to 15 in this case and is also what i is in the previous snippet:

/**
 * Explaining the gunID:
 * - if the gunID is odd, distance matters in choosing a firing angle.
 * - if the gunID/2 is odd, the lateral velocity at firetime matters in choosing a firing angle.
 * - if the gunID/4 is odd, the current acceleration/deceleration state is relavant in choosing a firing angle.
 * - if the gunID >= 8, the relationship to the wall is a relavant factor.
 * the same correlation is used to add stats to the buffer above, where the loop counter 'i' is equivalent to gunID.
**/
public int getStatIndex(int wall, int acc, int latv, int dist, int gunID)
{
	int tempdist = (gunID&1)*(dist+1);
	int templatv = ((gunID>>1)&1)*(latv+1);
	int tempacc = ((gunID>>2)&1)*(acc+1);
	int tempwall = ((gunID>>3)&1)*(wall+1);
	int bestindex = 15;
	int[] buffer = stats[tempwall][tempacc][templatv][tempdist];
	for (int i=0; i<31; i++)
	{
		if (buffer[i] > buffer[bestindex])
			bestindex = i;
	}
	return bestindex;
}

So all this should give you some idea what level of hackery I'm capable of when no one is looking, and what exactly powered the massive FloodHT 0.7 gun array (there were on the order of 30 guns, and 16 came from doing this, and 8 came from doing this on a different kind of gun). When I figured out, however, that FloodMini's gun was more effective than FloodHT's, I decided that the VG thing wasn't working for me, and after Iiley discovered the same problem in his work on a pre-release BlestPain, I tried to convince PEZ and Marshmallow to give up on it ;-) -- Kawigi


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited June 27, 2005 18:27 EST by Kawigi (diff)
Search: