private void theirBetAction(PerformedAction performedAction) { theirBetsThisStreet += performedAction.getAmount(); double potBet = (double) performedAction.getAmount() / (brain.potSize - performedAction.getAmount()); if (potBet < 0.2) return; theirRaiseHistory[currentState.ordinal()].add(performedAction.getAmount()); double PFR = adjustPFR(maj.getPFR()); double AGGRO = adjustAggro(maj.getAggression()); double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency()); double logFactor = HelperUtils.logisticSmall(3.0, 3.0, potBet) * Math.min( 100.0, (HelperUtils.logistic(400.0, 400.0, performedAction.getAmount()) + 300.0) / 4); if (currentState == GameState.PREFLOP) { changeEquity -= pfRaiseFactor * logFactor / PFR; } else { changeEquity -= pfRaiseFactor * logFactor / AGGROFREQ; } changeEquityCall = 0.0; }
@Test public void testCheckMappingWithoutDuplicates() throws IOException { Document simpleMapping = helperUtils.loadXmlFromPath(PATH_TO_SIMPLE_MAPPING); Document collInsideMapping = helperUtils.loadXmlFromPath(PATH_TO_COLLECTION_INSIDE_MAPPING); Document memberInsideMapping = helperUtils.loadXmlFromPath(PATH_TO_MEMBER_INSISDE_MAPPING); Document manyToOneMapping = helperUtils.loadXmlFromPath(PATH_TO_MANY_2_ONE_MAPPING); mappingValidator.checkDuplicateMappings(simpleMapping); mappingValidator.checkDuplicateMappings(collInsideMapping); mappingValidator.checkDuplicateMappings(memberInsideMapping); mappingValidator.checkDuplicateMappings(manyToOneMapping); }
private void theirRaiseAction(PerformedAction performedAction) { double potBet = (double) (performedAction.getAmount() - theirBetsThisStreet) / (brain.potSize - performedAction.getAmount()); if (potBet < 0.2) { theirBetsThisStreet += performedAction.getAmount(); return; } theirRaiseHistory[currentState.ordinal()].add(performedAction.getAmount()); double PFR = adjustPFR(maj.getPFR()); double AGGRO = adjustAggro(maj.getAggression()); double AGGROFREQ = adjustAggroFreq(maj.getAggressionFrequency()); double logFactor = HelperUtils.logisticSmall(3.0, 3.0, potBet) * Math.min( 100.0, (HelperUtils.logistic( 400.0, 400.0, performedAction.getAmount() - theirBetsThisStreet) + 300.0) / 4); double THREEB = maj.get3BetRate(); double TWOB = maj.get2BetRate(); if (myRaiseHistory[currentState.ordinal()].size() == 1 && theirRaiseHistory[currentState.ordinal()].size() == 1) { logFactor *= 1.0 + (0.2 - TWOB) * Math.min(100.0, myRaiseHistory[currentState.ordinal()].get(0)) / 30.0; } else if (theirRaiseHistory[currentState.ordinal()].size() == 2) { logFactor *= 1.0 + (0.25 - THREEB) * 1.5; } else if (theirRaiseHistory[currentState.ordinal()].size() >= 3) { logFactor *= 1.0 + (0.25 - THREEB) * 3.0; } if (currentState == GameState.PREFLOP) { changeEquity -= pfRaiseFactor * logFactor / PFR; } else { changeEquity -= pfRaiseFactor * logFactor / AGGROFREQ; } changeEquityCall = 0.0; theirBetsThisStreet += performedAction.getAmount(); }
private Action raise(int amount) { if (canRaise) return ActionUtils.raise( HelperUtils.minMax(amount, raiseAction.getMin(), raiseAction.getMax())); else if (canCall) return call(); else return fold(); }
@Test public void traverseNodesInGetterDuplicatesLevel3Test() throws IOException { Document xml = helperUtils.loadXmlFromPath(PATH_TO_GETTERS_LEVEL_3); Element root = xml.getDocumentElement(); NodeList mappings = root.getChildNodes(); Map<Integer, List<NodeAttributes>> nodesAttributesMap = new HashMap<>(); if (mappings != null) { for (int i = 0; i < mappings.getLength(); i++) { Node getter = mappings.item(i); mappingValidator.traverseNodes(1, getter.getChildNodes(), nodesAttributesMap); } } assertEquals(3, nodesAttributesMap.size()); List<NodeAttributes> output1 = nodesAttributesMap.get(1); NodeAttributes n1 = new NodeAttributes("1", null); NodeAttributes n11 = new NodeAttributes("1", "1"); assertTrue(output1.contains(n11)); int count = 0; for (NodeAttributes na : output1) { if (n1.equals(na)) { count++; } } assertEquals(3, count); List<NodeAttributes> output2 = nodesAttributesMap.get(2); NodeAttributes n2 = new NodeAttributes("2", null); NodeAttributes n22 = new NodeAttributes("2", "2"); int countN2 = 0; int countN22 = 0; for (NodeAttributes na : output2) { if (n2.equals(na)) { countN2++; } else if (n22.equals(na)) { countN22++; } } assertEquals(2, countN2); assertEquals(2, countN22); List<NodeAttributes> output3 = nodesAttributesMap.get(3); NodeAttributes n33 = new NodeAttributes("3", "3"); int count33 = 0; for (NodeAttributes na : output3) { if (n33.equals(na)) { count33++; } } assertEquals(2, count33); }
@Test public void traverseNodesInGetterDuplicatesTest() throws IOException { Document xml = helperUtils.loadXmlFromPath(PATH_TO_GETTER_DUPLICATES); Element root = xml.getDocumentElement(); NodeList mappings = root.getChildNodes(); Map<Integer, List<NodeAttributes>> nodesAttributesMap = new HashMap<>(); if (mappings != null) { for (int i = 0; i < mappings.getLength(); i++) { Node getter = mappings.item(i); mappingValidator.traverseNodes(1, getter.getChildNodes(), nodesAttributesMap); } } assertTrue(nodesAttributesMap.size() == 1); List<NodeAttributes> output = nodesAttributesMap.get(1); assertTrue(output.size() == 2); NodeAttributes expected = new NodeAttributes("s", "s"); assertEquals(output.get(0), expected); assertEquals(output.get(1), expected); }
@Test public void traverseNodesInSimpleMappingTest() throws IOException { Document xml = helperUtils.loadXmlFromPath(PATH_TO_SIMPLE_MAPPING); Element root = xml.getDocumentElement(); NodeList mappings = root.getChildNodes(); Map<Integer, List<NodeAttributes>> nodesAttributesMap = new HashMap<>(); if (mappings != null) { for (int i = 0; i < mappings.getLength(); i++) { Node getter = mappings.item(i); mappingValidator.traverseNodes(1, getter.getChildNodes(), nodesAttributesMap); } } assertTrue(nodesAttributesMap.size() == 1); List<NodeAttributes> output = nodesAttributesMap.get(1); assertTrue(output.contains(new NodeAttributes("s", "s"))); assertTrue(output.contains(new NodeAttributes("j", "j"))); assertTrue(output.contains(new NodeAttributes("l", "l"))); assertTrue(output.contains(new NodeAttributes("d", "d"))); assertTrue(output.contains(new NodeAttributes("c", "s"))); assertTrue(output.contains(new NodeAttributes("b", "s"))); }
private Action betPotPercentage( double percent, double inLo, double inHi, double outLo, double outHi) { double value = HelperUtils.linInterp(percent, inLo, inHi, outLo, outHi); return betPotPercentage(value); }
private Action betLin(double percent, double inLo, double inHi, double outLo, double outHi) { return bet(HelperUtils.linInterp(percent, inLo, inHi, outLo, outHi)); }
////////////// /////// BETTING ////////////// private Action bet(int amount) { if (canBet) return ActionUtils.bet(HelperUtils.minMax(amount, betAction.getMin(), betAction.getMax())); else if (canCall) return call(); else return fold(); }
@Test public void testSomething() throws IOException { Document xml = helperUtils.loadXmlFromPath(PATH_TO_SIMPLE_MAPPING); PojoAdapter pojoAdapter = new PojoAdapterImpl(xml); pojoAdapter.oneToOne(new Object().getClass(), new Object()); }
@Test(expected = IOException.class) public void testCheckMappingContainingGetterDuplicates() throws IOException { Document xml = helperUtils.loadXmlFromPath(PATH_TO_GETTER_DUPLICATES); mappingValidator.checkDuplicateMappings(xml); }
@Test(expected = IOException.class) public void testCheckXmlMappingContainingDuplicateManyToOneRel() throws IOException { Document xml = helperUtils.loadXmlFromPath(PATH_TO_MANY_TO_ONE_DUPLICATES); mappingValidator.checkDuplicateMappings(xml); }