id
stringlengths
36
36
text
stringlengths
1
1.25M
c9be8321-aa42-4ef9-9b34-aa0cc78573b8
public PasStartowy(String federateName) { super(federateName); }
fe3936a2-1a07-44c3-88d2-03efd585f5d9
@Override public void federateBody() throws RTIexception { //publish obiektu pasa int pasHandle = rti.getObjectClassHandle(Constants.OBIEKT_PAS_STARTOWY); int samolotHandle = rti.getAttributeHandle("samolot", pasHandle); AttributeHandleSet attributes = RtiFactoryFactory.getRtiFactory().createAttributeHandleSet...
8e58e366-36a9-4180-954e-0ed80dee487f
private void zmienStatusPasa(int pasStartowyHandle, int samolot) throws RTIexception { SuppliedAttributes attributes = RtiFactoryFactory.getRtiFactory().createSuppliedAttributes(); byte[] samolotValue = EncodingHelpers.encodeString("samolot:" + samolot); int classHandle = rti.getObjectClass(pasStartowyHandle); ...
6c4d46f5-e581-4143-81ed-f4cd46a5a428
@Override public boolean allFederatesReady() { return WiezaKontrolna.READY && Samolot.READY && PasStartowy.READY && Statystyka.READY; }
f7dddb3c-0d40-4c53-b3ed-71f98d532781
@Override public void imReady() { READY = true; }
2588f549-c0de-4687-8097-2533116f1a72
public PasStartowyAmbasador(String ambasadorName) { super(ambasadorName); }
2a21f72f-d3f1-4736-9fb7-36fa5e63dda3
@Override public void handleInteraction(int interactionClass, double time, ReceivedInteraction theInteraction) { try { samolot = Utils.getIntValue(theInteraction.getValue(0)); if (samolot > 0) { log("Rezerwacja dla: " + samolot); } } catch (ArrayIndexOutOfBounds ex) { } }
f3ba1ebf-e5bf-4936-b5c2-28146d22a5c9
@Override public void handleObjectParamsChanged(int theObject, double time, ReflectedAttributes theAttributes) { }
59a8d1fe-2149-41cd-8c80-2bdd911faa45
public Integer getSamolot() { return samolot; }
c2064c7b-d1f8-45a2-b2d2-fc077cac3a88
public void setSamolot(Integer samolot) { this.samolot = samolot; }
fc01ddcd-4e44-4d0c-9109-319be89aa136
public SamolotAmbasador(String ambasadorName) { super(ambasadorName); statusMap = new HashMap<Integer, Constants.AkcjaSamolotuEnum>(); czySpecjalnyMap = new HashMap<Integer, Boolean>(); }
959837ad-0d40-453c-b525-70eefbfd1df5
@Override public void handleInteraction(int interactionClass, double time, ReceivedInteraction interaction) { }
f031e1e6-dc7e-42de-a932-127df20d6b0a
@Override public void handleObjectParamsChanged(int theObject, double time, ReflectedAttributes theAttributes) { try { int samolot = Utils.getIntValue(theAttributes.getValue(0)); samolotDoObslugi = samolot; if (samolot > 0) { log("Samolot zajmuje pas: " + samolot); } } catch (Exception ex) { } }
129228ab-d9b2-422c-bcf9-8ab5aeb26992
public Map<Integer, AkcjaSamolotuEnum> getStatusMap() { return statusMap; }
21861e67-d38f-4ef0-869a-af4a6febd928
public Map<Integer, Boolean> getCzySpecjalnyMap() { return czySpecjalnyMap; }
d203216f-9126-48ae-9c6d-a944c79fc0b9
public Integer getSamolotDoObslugi() { return samolotDoObslugi; }
2339203c-3cfa-4fa1-8f30-552cda0a47de
void setSamolotDoObslugi(int samolotDoObslugi) { this.samolotDoObslugi = samolotDoObslugi; }
9e6cceca-fdd4-482b-90b5-3f7eb9f7f99d
@Test public void test() throws Exception { final String challenge = recaptcha.createChallenge(RECAPTCHA_PUBLIC_KEY); assertNotNull(challenge); final String imageUrl = recaptcha.getImageUrl(challenge); assertNotNull(imageUrl); }
9cf8c0d9-f759-430a-9824-c02c07cb7b58
@Override public String solve(String imageUrl) { return "123 456"; }
7de5d651-ed32-48e1-a9d8-69b28f1bf730
@Test public void testLoginWrongCaptcha() throws Exception { final FreebitcoinClient freebitcoin = new FreebitcoinClient(requestFactory, 5000, 5000, wrongRecaptchaSolver); try { freebitcoin.login(BITCOIN_ADDRESS, PASSWORD); fail("Expected exception."); } catch (FreebitcoinException e) { // Expected exce...
e1bae564-b77f-43ef-b409-6234ae3faa9b
@Test public void testLoginWrongPassword() throws Exception { final FreebitcoinClient freebitcoin = new FreebitcoinClient(requestFactory, 5000, 5000, manualRecaptchaSolver); try { freebitcoin.login(BITCOIN_ADDRESS, PASSWORD + "e"); fail("Expected exception."); } catch (FreebitcoinException e) { // Expec...
530d1759-e14d-4f5a-998f-45d0ac1bf7d9
@Test public void testLoginSuccess() throws Exception { final FreebitcoinClient freebitcoin = new FreebitcoinClient(requestFactory, 5000, 5000, manualRecaptchaSolver); freebitcoin.login(BITCOIN_ADDRESS, PASSWORD); }
2712e27d-7bd8-4412-9052-10ff478541ec
@Test public void testFreePlayWrongCaptcha() throws Exception { final FreebitcoinClient freebitcoin = new FreebitcoinClient(requestFactory, 5000, 5000, wrongRecaptchaSolver); try { freebitcoin.freePlay(BITCOIN_ADDRESS, TOKEN); fail("Expected exception."); } catch (FreebitcoinException e) { // Expected e...
bcdc6c2b-296f-42d3-bf33-ec6be86bf734
@Test public void testFreePlayWrongToken() throws Exception { final FreebitcoinClient freebitcoin = new FreebitcoinClient(requestFactory, 5000, 5000, wrongRecaptchaSolver); try { freebitcoin.freePlay(BITCOIN_ADDRESS, TOKEN + "e"); fail("Expected exception."); } catch (FreebitcoinException e) { // Expect...
8ec2111e-903f-4f58-a953-b4b9543c5dbe
@Test public void testFreeSuccess() throws Exception { final FreebitcoinClient freebitcoin = new FreebitcoinClient(requestFactory, 5000, 5000, manualRecaptchaSolver); try { freebitcoin.freePlay(BITCOIN_ADDRESS, TOKEN); } catch (FreebitcoinException e) { // "e3:2918" means "must wait 2918 more seconds" i...
72265694-bb78-4f6b-b943-6c622274ef84
private Endpoint(String url) { this.url = url; }
a34c3977-134f-4931-9158-637f4ce0f004
public RecaptchaClient(HttpRequestFactory requestFactory, Integer connectTimeout, Integer readTimeout, Endpoint endpoint) { this.requestFactory = requestFactory; this.connectTimeout = connectTimeout; this.readTimeout = readTimeout; this.endpoint = endpoint; }
ba73809f-5e61-4577-866f-b703ec41a649
public String createChallenge(String publicKey) throws IOException { final HttpRequest request = requestFactory.buildGetRequest(new GenericUrl( endpoint.url + "challenge?k=" + encode(publicKey))); if (connectTimeout != null) { request.setConnectTimeout(connectTimeout); } if (readTimeout != null) { req...
80e1b874-1352-4a7a-9418-d2a80043d255
public String getImageUrl(String challenge) { return endpoint.url + "image?c=" + encode(challenge); }
b4373ab8-83f6-4e36-99ef-5d6d3dad09e4
private static String encode(String s) { try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
96c8a038-a8f0-449c-ad05-9a70175cf187
@Override public int read(byte[] b) throws IOException { return System.in.read(b); }
7bb76b60-eb27-419a-a91c-d7c737794e66
@Override public int read(byte[] b, int off, int len) throws IOException { return System.in.read(b, off, len); }
aeb03a76-e25c-4712-955b-4b2275d7b893
@Override public long skip(long n) throws IOException { return System.in.skip(n); }
4c0e3cfa-b276-40a0-8642-2b7e5a16781f
@Override public int available() throws IOException { return System.in.available(); }
3df91ac0-6bfd-4e34-aabf-ff2293136976
@Override public synchronized void mark(int readlimit) { System.in.mark(readlimit); }
ac45561f-5cd8-49ea-a125-b130703af34b
@Override public synchronized void reset() throws IOException { System.in.reset(); }
f94caf4c-6a13-44ae-99b2-7c63ccdcebc2
@Override public boolean markSupported() { return System.in.markSupported(); }
d9cd47b9-fdbf-4f7e-855f-8f729ced93be
@Override public int read() throws IOException { return System.in.read(); }
7ce27fe4-dfd8-43c2-9e76-67ac2c7f94a8
@Override public String solve(String imageUrl) { System.out.print("Solve: " + imageUrl); final Scanner scanner = new Scanner(nonClosableSystemIn); try { return scanner.nextLine(); } finally { scanner.close(); } }
e0d1c3b6-1266-4298-bb2a-db817b1f489f
public String solve(String imageUrl);
32689a62-fa68-4d36-94ca-8c7630c95297
public FreebitcoinClient(HttpRequestFactory requestFactory, Integer connectTimeout, Integer readTimeout, CaptchaSolver captchaSolver) { this.requestFactory = requestFactory; this.connectTimeout = connectTimeout; this.readTimeout = readTimeout; this.captchaSolver = captchaSolver; recaptcha = new RecaptchaCl...
41bbc22d-7982-4f7c-b2e3-0146782663af
public String login(String btcAddress, String password) throws IOException, FreebitcoinException { final String recaptchaChallenge = recaptcha.createChallenge(RECAPTCHA_PUBLIC_KEY); final String recaptchaResponse = captchaSolver.solve(recaptcha.getImageUrl(recaptchaChallenge)); final Map<String, String> params...
bdb6dc70-57b6-4bb2-b44d-d539d18e12e7
private static String randomFingerprint() { final StringBuilder builder = new StringBuilder(); for (int i = 0; i < 32; ++i) { builder.append(Integer.toString(rand.nextInt(16), 16)); } return builder.toString(); }
1e41f937-0cc8-4b4e-b4be-584cf3795454
public FreePlayResult freePlay(String btcAddress, String token) throws IOException, FreebitcoinException { final String recaptchaChallenge = recaptcha.createChallenge(RECAPTCHA_PUBLIC_KEY); final String recaptchaResponse = captchaSolver.solve(recaptcha.getImageUrl(recaptchaChallenge)); final Map<String, String...
ccfe9271-1747-468e-85f6-a1c88eb59f01
private static String readFully(InputStream is) throws IOException { final byte[] buffer = new byte[1024*64]; final ByteArrayOutputStream baos = new ByteArrayOutputStream(); int numRead; while ((numRead = is.read(buffer)) != -1) { baos.write(buffer, 0, numRead); } return new String(baos.toByteArr...
b26b8efd-5ecc-43be-a3d7-00cc76e7b580
public FreebitcoinException(String message) { super(message); }
df86fdf0-fc03-4682-b265-44dd802f390b
public FreebitcoinException(String message, Throwable cause) { super(message, cause); }
9c94630a-4430-469e-9a7b-5172c0874940
public FreePlayResult(int roll, double balance, double payout, long timestamp) { this.roll = roll; this.balance = balance; this.payout = payout; this.timestamp = timestamp; }
7496ebed-a30e-4242-8f39-81b182c043bc
public Brain(NineMM game) { this.game = game; }
2f213224-06b1-4937-be89-d249164c1511
public void setStone(Node[] nodes, int type) { ArrayList<Node> mynodes = new ArrayList<Node>(); ArrayList<Node> enemynodes = new ArrayList<Node>(); ArrayList<Node> freenodes = new ArrayList<Node>(); boolean mill_created = false; Node selectedNode = null; for (Node n : nodes) { if (n.getIsBusy() == 0)...
5a515d03-afed-4e40-a8fc-14268dec6ebb
public void moveStone(Node[] nodes, int type) { Node[] move = new Node[2]; StateOfPlay currentStateOfPlay = new StateOfPlay(null, nodes,null, type,0,1); currentStateOfPlay.generatePossibilities(); for(StateOfPlay play : currentStateOfPlay.getChildren()){ System.out.println(play.getOriginMove()[0...
d9b293ef-8961-4f30-a72f-de3aa03cc1f9
public void jumpStone(Node[] nodes, int type) { System.out.println("AI: Jump, jump"); ArrayList<Node> mynodes = new ArrayList<Node>(); ArrayList<Node> enemynodes = new ArrayList<Node>(); ArrayList<Node> freenodes = new ArrayList<Node>(); boolean mill_created = false; Node sourceNode = null; Node destinat...
f933f993-be1a-4255-9fb6-99d8a1720f1c
public void deleteStone(Node[] nodes, int type) { ArrayList<Node> mynodes = new ArrayList<Node>(); ArrayList<Node> enemynodes = new ArrayList<Node>(); ArrayList<Node> freenodes = new ArrayList<Node>(); Node selectedNode = null; for (Node n : nodes) { if (n.getIsBusy() == 0) { freenodes.add(n); co...
8cad7959-50c1-4095-addf-254dbfc21c1a
private Node findMaxFreeNodes(ArrayList<Node> nodes){ int maxval = 0; Node result = null; for(Node n : nodes){ int num = 0; for(Node f : n.getNeighbours()){ if(f.getIsBusy() == 0){ num++; } } if(num>=maxval){ maxval = num; result = n; } } return result; }
e3429aa0-ce65-4d16-ac11-09320daf1873
private Node findMillDraw(ArrayList<Node> busynodes, ArrayList<Node> freenodes) { Node selectedNode = null; for (Node n : busynodes) { for (Node m : n.getNeighbours()) { if (busynodes.contains(m)) { for (Node f : m.getNeighbours()) { if (freenodes.contains(f) && ((f.location.x == m.loca...
9da3f455-d2d7-49de-91c7-826f0e59682d
public StateOfPlay(StateOfPlay parent, Node[] nodes2copy, Node[] originMove, int type, int level, int depth) { this.parent = parent; this.type = type; this.level = level; this.depth = depth; if (level % 2 == 0) { player = type; } else { if (type == 1) { player = 2; } else { player = 1; ...
860c1ce7-be8c-44da-8eeb-258269605324
public void generatePossibilities() { // System.out.println("---generating--level -" + (level+1) + // "----------------------"); if (depth >= 0) { for (int i = 0; i < this.nodes.length; i++) { if (this.nodes[i].getIsBusy() == player) { for (Node potential : this.nodes[i].getNeighbours()) { if (p...
21c83b4d-3328-43c5-b3c3-f7736b705cbc
private Node findForDeletion() { analyzeNodes(); Node selectedNode = null; for (Node n : enemynodes) { selectedNode = n; for (Node m : n.getNeighbours()) { if (enemynodes.contains(m)) { selectedNode = m; break; } if (freenodes.contains(m)){ for(Node last : m.getNeighbours()){ ...
34747748-00b9-4760-aa4a-3f2060e0ddd7
private void analyzeNodes() { freenodes.clear(); mynodes.clear(); enemynodes.clear(); for (int i = 0; i < this.nodes.length; i++) { if (nodes[i].getIsBusy() == 0) { this.freenodes.add(nodes[i]); continue; } if (nodes[i].getIsBusy() == player) { this.mynodes.add(nodes[i]); continue; }...
01f4fd0b-4deb-4cca-bd26-d2197a32891f
private boolean checkNodeInMill(Node node, int p) { System.out.println("---------------------------------"); System.out.println("we wanted to move " + nodes[p].getId() +","+nodes[p].getIsBusy()+ " to: "+node.getId() + ","+node.getIsBusy()); analyzeNodes(); for (Node n : mynodes) { for (Node m : n.get...
bc698f6a-9a4f-4fc1-82c6-983e69a07293
public boolean deleteSomething() { if (rememberDeletion == null) { return false; } else { return true; } }
53842d8e-e762-414c-9355-b4e986967406
public StateOfPlay calculateBestEffort() { StateOfPlay result = null; int maxval = this.children.get(0).getValue(); for (StateOfPlay child : this.children) { if (child.value >= maxval) { maxval = child.value; result = child; } } return result; }
89d03c9d-d817-40fb-a3c1-51a67389b590
public Node getRememberDeletion() { return rememberDeletion; }
8d335e79-ef13-44a8-9483-a1b313cde607
public void setRememberDeletion(Node rememberDeletion) { this.rememberDeletion = rememberDeletion; }
51425626-6cdf-4dc2-9de9-2bb10c2f84df
public int getType() { return type; }
1bfb9c4f-7253-4ea1-b2f3-280d7566a1d8
public int getPlayer() { return player; }
95ef2a07-0455-465a-8d99-b4f165e3d4ad
public int getValue() { return value; }
b95b242c-93f0-4de9-9a71-56818ee23c49
public void setValue(int value) { this.value = value; }
ffdf06ba-f7fb-4176-83a9-cf9a7a2a3f64
public int getLevel() { return level; }
9ed6f31e-aa52-4615-931e-eeccf515f3c6
public void setLevel(int level) { this.level = level; }
ec16a452-4e71-40ac-b2b2-09d543631cc6
public StateOfPlay getParent() { return parent; }
69dac0da-07ce-4ccc-93bf-83a9466acf3d
public void setParent(StateOfPlay parent) { this.parent = parent; }
813924a3-4331-4612-bd3a-7c78973b218d
public ArrayList<StateOfPlay> getChildren() { return children; }
9792423e-7140-4c4f-a55f-68aec1663100
public void setChildren(ArrayList<StateOfPlay> children) { this.children = children; }
80625dec-69b9-4ddf-a783-2385833706b9
public Node[] getOriginMove() { return originMove; }
240d4608-d6b7-4703-9c0a-b9f4b8f07e1e
public void setOriginMove(Node[] originMove) { this.originMove = originMove; }
241fb1a9-1ee7-4063-972d-12413ee2ee47
public Referee(NineMM game) { this.game = game; }
66ddc488-543b-4f1a-9aa6-8340770232bc
public boolean checkRules(Node[] nodes, boolean isWhitesTurn) { this.isWhitesTurn = isWhitesTurn; boolean check = checkMill(nodes); checkEndOfGame(nodes); return check; }
0cd62106-e50d-449a-965f-e0440fe6e495
public void checkEndOfGame(Node[] nodes) { if(game.getPlacedCounter() < 18){ //System.out.println("Pieces placed: " + game.getPlacedCounter()); } else{ // check for int countblackoptions = 0; int countwhiteoptions = 0; for(int i = 0; i < nodes.length; i++ ){ for(Node n : nodes[i].getNeighbo...
bf629175-61d1-4f5d-95e1-c7aa6985ec15
private boolean checkMill(Node[] nodes) { ArrayList<Node> whiteOccupants = new ArrayList<Node>(); ArrayList<Node> blackOccupants = new ArrayList<Node>(); int old_black_mills = 0; int old_white_mills = 0; for (int i = 0; i < nodes.length; i++) { if (nodes[i].getIsBusy() == 1) whiteOccupants.add(nodes[i...
8761d233-7686-43ea-ac38-c4c88e587719
public boolean isStart() { return start; }
9481a1cd-313e-46ba-af6c-2fe7fd392719
public void setStart(boolean start) { this.start = start; }
c7316793-7dbe-4458-903a-965a159c11b2
public String getPlayer1() { return player1; }
08a47d9b-4cb4-4cf5-9809-3dbc773f87dd
public void setPlayer1(String player1) { this.player1 = player1; }
b64dcbac-95a2-4396-a215-c8ba2227f0d3
public String getPlayer2() { return player2; }
c699f15c-54b0-4c21-80b2-65be1841b98e
public void setPlayer2(String player2) { this.player2 = player2; }
2eb70d34-df2f-4f03-a64b-f810ab7254fb
public void printProperties() { System.out.println("Start: " + start); System.out.println("Player 1: " + player1); System.out.println("Player 2: " + player2); }
f221d4d8-e0de-4a96-9686-e71380bbfb08
public Splashscreen() { setTitle("9MM - Nine Men's Morris"); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); setBounds((dim.width/2-(a...
48ba09fe-8a78-404c-bc29-93ddb618a769
public void actionPerformed(ActionEvent arg0) { setting.setStart(true); if(rbtn_player1_human.isSelected()){ setting.setPlayer1(rbtn_player1_human.getName()); } else{ setting.setPlayer1(rbtn_player1_computer.getName()); } if(rbtn_player2_human.isSelected()){ ...
b380805c-e77b-4170-a42d-ea35a0d0e68a
public void run() { try { NineMM window = new NineMM(setting); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
1e00b794-47e4-48f5-a9b6-4fb27e1f4223
@Override public void mouseClicked(MouseEvent arg0) { System.exit(0); }
1fa27aeb-9307-47d0-add4-dca975e73094
public static void main(String[] args) { // EventQueue.invokeLater(new Runnable() { // public void run() { // try { // NineMM window = new NineMM(null); // window.frame.setVisible(true); // } catch (Exception e) { // e.printStackTrace(); // } // } // }); splash = new Splashscreen(); splash.set...
92170336-bb2e-4bb8-91ef-8f245118be51
public NineMM(Settings setting) { this.setting = setting; splash.dispose(); initializeWindow(); initializeGameField(); }
f0754b4c-ad6e-4cc5-a167-90ad698d33ab
private void initializeWindow() { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame = new JFrame(); frame.setBounds((dim.width / 2 - (appWidth / 2)), (dim.height / 2 - (appHeigth / 2)), appWidth, appHeigth); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setL...
10ab32dd-0633-4ceb-a136-e1af06a4e004
public void actionPerformed(ActionEvent arg0) { System.exit(0); }
5cfa93be-cec1-4563-879d-b19d15580dcb
private void initializeGameField() { ImageIcon iconWhite = createImageIcon("/resources/White_Stone.png"); int space = 0; blacks = new JLabel[9]; whites = new JLabel[9]; for (int i = 0; i < 9; i++) { final JLabel lblWhite = new JLabel(iconWhite); lblWhite.addMouseListener(new MouseAdapter() { @Over...
f7d41792-662f-4aeb-b1cd-6c5b2ca20b69
@Override public void mouseClicked(MouseEvent e) { // if(deleteFlag && whitesTurn){ // System.out.println("delete Stein"); // deleteFlag = false; // lblWhite.setVisible(false); // lblWhite.setLocation(0, 0); // for(Point p : placedPieces){ // if(p.x == lblWhite.getBounds().x && p....
5982788c-0eba-4929-ae09-42caf7d36fba
@Override public void mouseClicked(MouseEvent e) { // if(deleteFlag && blacksTurn){ // System.out.println("delete Stein"); // deleteFlag = false; // lblBlack.setVisible(false); // for(Point p : placedPieces){ // if(p.x == lblBlack.getBounds().x && p.y == lblBlack.getBounds().y){ // ...
7fe15339-6a7d-44fa-9d3c-a4bc304789c8
public void doSomething(Point point) { if(whitesTurn){ JLabel lblWhite = getLabel(point); if(deleteFlag && whitesTurn){ if(getNode(point).getIsBusy() == 1){ //System.out.println("delete Stein"); deleteFlag = false; getNode(lblWhite.getBounds().getLocation()).setIsBusy(0); lblWhite.set...
d927af0f-7506-414e-ba56-d32fad25b21e
private JLabel getLabel(Point point) { JLabel label = null; JLabel[] searchLabel; if(whitesTurn){ searchLabel = whites; } else{ searchLabel = blacks; } for(JLabel l : searchLabel){ if(l.getBounds().x == point.x && l.getBounds().y == point.y){ label = l; } } return label; }