Package cz.matfyz.aai.fantom.game

Examples of cz.matfyz.aai.fantom.game.Graph


    catch(Exception err) {
      System.err.println("Invalid graph file name");
      printUsage();
      return;
    }
    Graph graph = null;
    try {
      graph = new Graph(graphFile);
    }
    catch(IOException e) {
      System.err.println("Could not read the graph file");
      e.printStackTrace();
    } catch (ParserException e) {
View Full Code Here


   * Returns the game graph sent along with this message.
   * @return the game graph sent along with this message.
   */
  public Graph getGraph() throws GraphFormatException {
    if(this.graph == null) {
      this.graph = new Graph(messageData);
    }
    return this.graph;
  }
View Full Code Here

    assertEquals("bus", record.getProperty(MessageMoveBase.PROPERTY_TRANSPORT_TYPE));
  }
 
  public static final String ACTOR_MOVE_MISSING_DATA = "actor: Fantomas";
  public void testLoadInvalidActorMove() throws Exception {
    Graph g = new Graph(TEST_GRAPH);
   
    try {
      new ActorMove(g, Parser.parseLine(ACTOR_MOVE_MISSING_DATA));
      fail("Actor move was loaded without transport type and target node");
    }
View Full Code Here

    "tickets: Poirot, tram: 10, double: 1",
    "tickets: Joker, tram: 2, double: 2",
    "tickets: Batman, tram: 2",
  };
  public void testLoadUpdatePhantom() throws Exception {
    Graph g = new Graph(TEST_GRAPH);
   
    MessageUpdate msg = new MessageUpdate(g, Parser.parseLines(MESSAGE_UPDATE_PHANTOM));

    TransportType tram = g.getTransportType("tram");
    assertNotNull(tram);

    ActorMove[] moves = msg.getMoves();
    assertNotNull(moves);
    assertEquals(2, moves.length);
    assertNotNull(moves[0].getActor());
    assertSame(g.getActor("Fantomas"), moves[0].getActor());
    assertNotNull(moves[0].getTransportType());
    assertSame(tram, moves[0].getTransportType());
    assertNull(moves[0].getTargetNode());
   
    assertNotNull(moves[1].getActor());
    assertSame(g.getActor("Joker"), moves[1].getActor());
    assertNotNull(moves[1].getTransportType());
    assertSame(tram, moves[1].getTransportType());
    assertNull(moves[1].getTargetNode());
   
    assertNotNull(msg.getCapturedPhantoms());
    assertEquals(0, msg.getCapturedPhantoms().size());
   
    ActorTickets[] tickets = msg.getActorTickets();
    assertNotNull(tickets);
    assertEquals(4, tickets.length);
   
    assertNotNull(tickets[0]);
    assertNotNull(tickets[0].getActor());
    assertSame(g.getActor("Fantomas"), tickets[0].getActor());
    assertNotNull(tickets[0].getTickets());
    assertEquals(1, tickets[0].getTickets().size());
    assertNotNull(tickets[0].getTickets().get(tram));
    assertEquals(10, tickets[0].getTickets().get(tram).intValue());
    assertEquals(0, tickets[0].getDoubleTickets());
   
    assertNotNull(tickets[1]);
    assertNotNull(tickets[1].getActor());
    assertSame(g.getActor("Poirot"), tickets[1].getActor());
    assertNotNull(tickets[1].getTickets());
    assertEquals(1, tickets[1].getTickets().size());
    assertNotNull(tickets[1].getTickets().get(tram));
    assertEquals(10, tickets[1].getTickets().get(tram).intValue());
    assertEquals(1, tickets[1].getDoubleTickets());
   
    assertNotNull(tickets[2]);
    assertNotNull(tickets[2].getActor());
    assertSame(g.getActor("Joker"), tickets[2].getActor());
    assertNotNull(tickets[2].getTickets());
    assertEquals(1, tickets[2].getTickets().size());
    assertNotNull(tickets[2].getTickets().get(tram));
    assertEquals(2, tickets[2].getTickets().get(tram).intValue());
    assertEquals(2, tickets[2].getDoubleTickets());
   
    assertNotNull(tickets[3]);
    assertNotNull(tickets[3].getActor());
    assertSame(g.getActor("Batman"), tickets[3].getActor());
    assertNotNull(tickets[3].getTickets());
    assertEquals(1, tickets[3].getTickets().size());
    assertNotNull(tickets[3].getTickets().get(tram));
    assertEquals(2, tickets[3].getTickets().get(tram).intValue());
    assertEquals(0, tickets[3].getDoubleTickets());
View Full Code Here

    "tickets: Fantomas, tram: 15",
    "tickets: Joker, tram: 2",
    "tickets: Batman, tram: 3",
  };
  public void testLoadPlacementDetective() throws Exception {
    Graph g = new Graph(TEST_GRAPH);
   
    MessageUpdate msg = new MessageUpdate(g, Parser.parseLines(MESSAGE_PLACEMENT_DETECTIVE));
   
    TransportType tram = g.getTransportType("tram");
    assertNotNull(tram);
   
    ActorMove[] moves = msg.getMoves();
    assertNotNull(moves);
    assertEquals(2, moves.length);
   
    assertNotNull(moves[0]);
    assertNotNull(moves[0].getActor());
    assertSame(g.getActor("Poirot"), moves[0].getActor());
    assertNotNull(moves[0].getTargetNode());
    assertSame(g.getNode("1"), moves[0].getTargetNode());
    assertNull(moves[0].getTransportType());
   
    assertNotNull(moves[1]);
    assertNotNull(moves[1].getActor());
    assertSame(g.getActor("Batman"), moves[1].getActor());
    assertNotNull(moves[1].getTargetNode());
    assertSame(g.getNode("2"), moves[1].getTargetNode());
    assertNull(moves[1].getTransportType());
   
    assertNotNull(moves[1]);
   
    assertNotNull(msg.getCapturedPhantoms());
View Full Code Here

    "actor: Poirot, to: 2, transport: tram",
    "actor: Batman, to: 3, transport: bus",
    "captured: Joker",
  };
  public void testLoadUpdateDetective() throws Exception {
    Graph g = new Graph(TEST_GRAPH);
   
    MessageUpdate msg = new MessageUpdate(g, Parser.parseLines(MESSAGE_UPDATE_DETECTIVE));
     
    ActorMove[] moves = msg.getMoves();
    assertNotNull(moves);
    assertEquals(2, moves.length);
   
    assertNotNull(moves[0]);
    assertNotNull(moves[0].getActor());
    assertSame(g.getActor("Poirot"), moves[0].getActor());
    assertNotNull(moves[0].getTargetNode());
    assertSame(g.getNode("2"), moves[0].getTargetNode());
    assertNotNull(moves[0].getTransportType());
    assertSame(g.getTransportType("tram"), moves[0].getTransportType());
   
    assertNotNull(moves[1]);
    assertNotNull(moves[1].getActor());
    assertSame(g.getActor("Batman"), moves[1].getActor());
    assertNotNull(moves[1].getTargetNode());
    assertSame(g.getNode("3"), moves[1].getTargetNode());
    assertNotNull(moves[1].getTransportType());
    assertSame(g.getTransportType("bus"), moves[1].getTransportType());
   
    assertNotNull(msg.getCapturedPhantoms());
    assertEquals(1, msg.getCapturedPhantoms().size());
    assertTrue(msg.getCapturedPhantoms().contains(g.getActor("Joker")));
  }
View Full Code Here

    assertEquals(1, msg.getCapturedPhantoms().size());
    assertTrue(msg.getCapturedPhantoms().contains(g.getActor("Joker")));
  }
 
  public void testSerializeMessageUpdate() throws Exception {
    Graph g = new Graph(TEST_GRAPH);
   
    Actor fantomas = g.getActor("Fantomas");
    assertNotNull(fantomas);
    Actor poirot = g.getActor("Poirot");
    assertNotNull(poirot);
    Actor batman = g.getActor("Batman");
    assertNotNull(batman);
    Actor joker = g.getActor("Joker");
    assertNotNull(joker);
   
    TransportType bus = g.getTransportType("bus");
    assertNotNull(bus);
    TransportType tram = g.getTransportType("tram");
    assertNotNull(tram);
   
    Node n3 = g.getNode("3");
    assertNotNull(n3);
    Node n4 = g.getNode("4");
    assertNotNull(n4);
   
    ActorMove[] moves = new ActorMove[] {
        new ActorMove(fantomas, n3, null),
        new ActorMove(poirot, null, bus),
View Full Code Here

    "detective: Poirot, tram: 10",
    "detective: Batman, tram: 10",
  };
 
  public void testCreateActorMoveMissingValues() throws Exception {
    Graph g = new Graph(TEST_GRAPH);
   
    Actor fantomas = g.getActor("Fantomas");
    assertNotNull(fantomas);
   
    try {
      new ActorMove(null, null, null);
      fail("ActorMove was successfully created with null values");
    }
    catch(IllegalArgumentException e) {
      // OK, let's go on
    }
   
    try {
      new ActorMove(fantomas, null, null);
      fail("ActorMove was successfully created with null target node and null transport type");
    }
    catch(IllegalArgumentException e) {
      // OK, let's go on
    }
   
    // Let's try if we can create ActorMoves with either just a transport
    // type, or a target node
    ActorMove move;
    move = new ActorMove(fantomas, g.getNode("1"), null);
    assertSame(fantomas, move.getActor());
    assertNotNull(move.getTargetNode());
    assertSame(g.getNode("1"), move.getTargetNode());
    assertNull(move.getTransportType());
   
    move = new ActorMove(fantomas, null, g.getTransportType("bus"));
    assertSame(fantomas, move.getActor());
    assertNull(move.getTargetNode());
    assertNotNull(move.getTransportType());
    assertSame(g.getTransportType("bus"), move.getTransportType());
   
    move = new ActorMove(fantomas, g.getNode("2"), g.getTransportType("tram"));
    assertSame(fantomas, move.getActor());
    assertNotNull(move.getTargetNode());
    assertSame(g.getNode("2"), move.getTargetNode());
    assertNotNull(move.getTransportType());
    assertSame(g.getTransportType("tram"), move.getTransportType());
  }
View Full Code Here

    assertNotNull(move.getTransportType());
    assertSame(g.getTransportType("tram"), move.getTransportType());
  }
 
  public void testSerializeActorMove() throws Exception {
    Graph g = new Graph(TEST_GRAPH);
   
    Actor fantomas = g.getActor("Fantomas");
    assertNotNull(fantomas);
   
    Node nd1 = g.getNode("1");
    assertNotNull(nd1);
   
    TransportType bus = g.getTransportType("bus");
    assertNotNull(bus);
   
    ActorMove move = new ActorMove(fantomas, nd1, null);
    Properties record = move.serialize();
   
View Full Code Here

TOP

Related Classes of cz.matfyz.aai.fantom.game.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.