@Test public void testAddress() throws Exception { Tiling2048 tiling2048 = Tiling2048.createWithRandomWeights(1, 15, new int[] { 7, 8, 9, 10, 15, 16 }, 16, 0, 0, new RandomDataGenerator(new MersenneTwister(123))); Assert.assertEquals(0, tiling2048.address(new State2048( new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }))); Assert.assertEquals(0, tiling2048.address(new State2048( new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 }))); Assert.assertEquals(0, tiling2048.address(new State2048( new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14 }))); Assert.assertEquals(0, tiling2048.address(new State2048( new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 14, 12, 14 }))); Assert.assertEquals(1<<24, tiling2048.address(new State2048( new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15 }))); Assert.assertEquals(1, tiling2048.address(new State2048( new double[] { 0,0,0,0, 0,0,0,1, 0,0,0,0, 0,0,0,0 }))); Assert.assertEquals(16+1, tiling2048.address(new State2048( new double[] { 0,0,0,0, 0,0,1,1, 0,0,0,0, 0,0,0,0 }))); Assert.assertEquals((1<<20)+16+1, tiling2048.address(new State2048( new double[] { 1,0,0,0, 0,0,1,1, 0,0,0,0, 0,0,0,0 }))); Assert.assertEquals(3*(1<<20)+2*16+1, tiling2048.address(new State2048( new double[] { 3,0,0,0, 0,0,2,1, 0,0,0,0, 0,0,0,0 }))); Assert.assertEquals((1<<24) + 3*(1<<20)+2*16+1, tiling2048.address(new State2048( new double[] { 3,0,0,0, 0,0,2,1, 0,0,0,0, 0,0,15,0 }))); Assert.assertEquals((1<<24) + 3*(1<<20)+15*16+1, tiling2048.address(new State2048( new double[] { 3,0,0,0, 0,0,15,1, 0,0,0,0, 0,0,15,0 }))); Assert.assertEquals((1<<24) + 3*(1<<20)+15*16+1, tiling2048.address(new State2048( new double[] { 3,0,0,0, 0,0,15,1, 0,0,0,0, 0,0,0,0 }))); }
public int address(State2048 state) { int[] values = state.getValues(); int address = 0; for (int i = 0; i < numSegments; ++i) { address *= 2; address += state.hasValue(values, maxSegment - i) ? 1 : 0; } for (int i = 0; i < straightLocations.length; ++i) { address *= numTileValues; address += state.getValue(straightLocations[i]); } return address; }
Tiling2048 implements Serializable { public int address(State2048 state) { int[] values = state.getValues(); int address = 0; for (int i = 0; i < numSegments; ++i) { address *= 2; address += state.hasValue(values, maxSegment - i) ? 1 : 0; } for (int i = 0; i < straightLocations.length; ++i) { address *= numTileValues; address += state.getValue(straightLocations[i]); } return address; } }
Tiling2048 implements Serializable { public int address(State2048 state) { int[] values = state.getValues(); int address = 0; for (int i = 0; i < numSegments; ++i) { address *= 2; address += state.hasValue(values, maxSegment - i) ? 1 : 0; } for (int i = 0; i < straightLocations.length; ++i) { address *= numTileValues; address += state.getValue(straightLocations[i]); } return address; } Tiling2048(int[] locations, float[] weights, int numTileValues, int numSegments, int maxSegment); }
Tiling2048 implements Serializable { public int address(State2048 state) { int[] values = state.getValues(); int address = 0; for (int i = 0; i < numSegments; ++i) { address *= 2; address += state.hasValue(values, maxSegment - i) ? 1 : 0; } for (int i = 0; i < straightLocations.length; ++i) { address *= numTileValues; address += state.getValue(straightLocations[i]); } return address; } Tiling2048(int[] locations, float[] weights, int numTileValues, int numSegments, int maxSegment); int getMaxSegment(); int[] getLocations(); float[] getLUT(); static Tiling2048 createWithSharedWeights(Tiling2048 template, int[] locations); int stageBegins(int stage); int address(State2048 state); static int computeNumWeights(int numTileValues, int numLocations, int numSegments); double getValue(State2048 state); int addressSpecial(State2048 state); double getValueSpecial(State2048 state); double getValueSuperSpecial(State2048 state); void setValue(State2048 state, float value); void increaseValue(State2048 state, float delta); int getNumWeights(); int getNumSegments(); int getNumTileValues(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static List<Tiling2048> createSymmetric(Tiling2048 template, SymmetryExpander expander); static Tiling2048 createWithRandomWeights(int numSegments, int maxSegment, int[] locations, int numValues,
			double minWeight, double maxWeight, RandomDataGenerator random); int getNumLocations(); }
Tiling2048 implements Serializable { public int address(State2048 state) { int[] values = state.getValues(); int address = 0; for (int i = 0; i < numSegments; ++i) { address *= 2; address += state.hasValue(values, maxSegment - i) ? 1 : 0; } for (int i = 0; i < straightLocations.length; ++i) { address *= numTileValues; address += state.getValue(straightLocations[i]); } return address; } Tiling2048(int[] locations, float[] weights, int numTileValues, int numSegments, int maxSegment); int getMaxSegment(); int[] getLocations(); float[] getLUT(); static Tiling2048 createWithSharedWeights(Tiling2048 template, int[] locations); int stageBegins(int stage); int address(State2048 state); static int computeNumWeights(int numTileValues, int numLocations, int numSegments); double getValue(State2048 state); int addressSpecial(State2048 state); double getValueSpecial(State2048 state); double getValueSuperSpecial(State2048 state); void setValue(State2048 state, float value); void increaseValue(State2048 state, float delta); int getNumWeights(); int getNumSegments(); int getNumTileValues(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static List<Tiling2048> createSymmetric(Tiling2048 template, SymmetryExpander expander); static Tiling2048 createWithRandomWeights(int numSegments, int maxSegment, int[] locations, int numValues,
			double minWeight, double maxWeight, RandomDataGenerator random); int getNumLocations();  }