@Test public void choosePieceOneInterestingTest() { BitSet interesting = new BitSet(); for (int i = 0; i < myPieces.length; i++) { interesting.clear(); interesting.set(i); Piece expected = myPieces[i]; Piece actual = myRequestStrategy.choosePiece(interesting, myPieces); Assert.assertEquals(expected, actual); } }
@Override public Piece choosePiece(BitSet interesting, Piece[] pieces) { List<Piece> onlyInterestingPieces = new ArrayList<Piece>(); for (Piece p : pieces) { if (interesting.get(p.getIndex())) onlyInterestingPieces.add(p); } if (onlyInterestingPieces.isEmpty()) return null; return onlyInterestingPieces.get(myRandom.nextInt(onlyInterestingPieces.size())); }
RequestStrategyImplAnyInteresting implements RequestStrategy { @Override public Piece choosePiece(BitSet interesting, Piece[] pieces) { List<Piece> onlyInterestingPieces = new ArrayList<Piece>(); for (Piece p : pieces) { if (interesting.get(p.getIndex())) onlyInterestingPieces.add(p); } if (onlyInterestingPieces.isEmpty()) return null; return onlyInterestingPieces.get(myRandom.nextInt(onlyInterestingPieces.size())); } }
RequestStrategyImplAnyInteresting implements RequestStrategy { @Override public Piece choosePiece(BitSet interesting, Piece[] pieces) { List<Piece> onlyInterestingPieces = new ArrayList<Piece>(); for (Piece p : pieces) { if (interesting.get(p.getIndex())) onlyInterestingPieces.add(p); } if (onlyInterestingPieces.isEmpty()) return null; return onlyInterestingPieces.get(myRandom.nextInt(onlyInterestingPieces.size())); }  }
RequestStrategyImplAnyInteresting implements RequestStrategy { @Override public Piece choosePiece(BitSet interesting, Piece[] pieces) { List<Piece> onlyInterestingPieces = new ArrayList<Piece>(); for (Piece p : pieces) { if (interesting.get(p.getIndex())) onlyInterestingPieces.add(p); } if (onlyInterestingPieces.isEmpty()) return null; return onlyInterestingPieces.get(myRandom.nextInt(onlyInterestingPieces.size())); }  @Override Piece choosePiece(BitSet interesting, Piece[] pieces); }
RequestStrategyImplAnyInteresting implements RequestStrategy { @Override public Piece choosePiece(BitSet interesting, Piece[] pieces) { List<Piece> onlyInterestingPieces = new ArrayList<Piece>(); for (Piece p : pieces) { if (interesting.get(p.getIndex())) onlyInterestingPieces.add(p); } if (onlyInterestingPieces.isEmpty()) return null; return onlyInterestingPieces.get(myRandom.nextInt(onlyInterestingPieces.size())); }  @Override Piece choosePiece(BitSet interesting, Piece[] pieces);  }