Package com.jcloisterzone.board

Examples of com.jcloisterzone.board.Tile


            return ((FarmScoreContext) featureCtx).getPoints(aiPlayer.getPlayer());
        }
    }

    private double futureConnectionRateConnection(Game game, Location toEmpty, Location toFeature, Position f2Pos, double chance) {
        Tile tile1 = game.getCurrentTile();
        Tile tile2 = game.getBoard().get(f2Pos);

        double rating = 0;

        Completable f1 = (Completable) tile1.getFeaturePartOf(toEmpty);
        Completable f2 = (Completable) tile2.getFeaturePartOf(toFeature.rev());

        if (f1 != null && f2 != null) {
            if (f1.getClass().equals(f2.getClass())) {
                //            System.err.println("    " + tile1.getPosition() + " <-->" + f2Pos + " / " + f1 + " " + f2);
                rating +=  futureConnectionRateFeatures(game, toEmpty, toFeature, chance, f1, f2);
            } else {
                rating +=  futureConnectionRateCrossing(game, toEmpty, toFeature, chance, f1, f2);
            }
        }

        if (toEmpty != toFeature) {
            boolean left = toEmpty.rotateCCW(Rotation.R90) == toFeature;
            Farm farm1 = (Farm) tile2.getFeaturePartOf(left ? toEmpty.getLeftFarm() : toEmpty.getRightFarm());
            Farm farm2 = (Farm) tile2.getFeaturePartOf(left ? toFeature.rev().getRightFarm() : toFeature.rev().getLeftFarm());

            if (farm1 != null && farm2 != null) {
//                System.err.println("    " + tile1.getPosition() + " <-->" + f2Pos + " / " + farm1 + " " + farm2);
                rating +=  futureConnectionRateFeatures(game, toEmpty, toFeature, chance, farm1, farm2);
            }
View Full Code Here


    }

    private double rankPossibleFeatureConnections(Game game) {
        double rank = 0;

        Tile tile = game.getCurrentTile();
        Position placement = tile.getPosition();
        assert placement != null;

        for (Entry<Location, Position> eplace : Position.ADJACENT.entrySet()) {
            Position pos = placement.add(eplace.getValue());
            if (game.getBoard().get(pos) != null) continue;

            double chance = chanceToPlaceTile(game, pos);
            if (chance < MIN_CHANCE) continue;

            for (Entry<Location, Position> econn : Position.ADJACENT.entrySet()) {
                Position conn = pos.add(econn.getValue());
                if (conn.equals(placement)) continue;
                Tile connTile = game.getBoard().get(conn);
                if (connTile == null) continue;

                rank += futureConnectionRateConnection(game, eplace.getKey(), econn.getKey(), conn, chance);
            }
        }
View Full Code Here

        assertEquals(expected, ctx.getPoints());
    }

    @Test
    public void simple() {
        Tile t;
        t = putTile(new Position(0,0), Rotation.R0, Expansion.BASIC, "RCr");
        putTile(new Position(1,0), Rotation.R0, Expansion.BASIC, "RFr");
        putTile(new Position(-1,0), Rotation.R0, Expansion.BASIC, "RRRR");
        putTile(new Position(2,0), Rotation.R90, Expansion.BASIC, "LR");
View Full Code Here

        assertScore(4, t, Location.W);
    }

    @Test
    public void circle() {
        Tile t;
        t = putTile(new Position(0,0), Rotation.R0, Expansion.BASIC, "Rr");
        putTile(new Position(-1,0), Rotation.R270, Expansion.BASIC, "Rr");
        putTile(new Position(0,1), Rotation.R90, Expansion.BASIC, "RrC");
        putTile(new Position(-1,1), Rotation.R270, Expansion.BASIC, "CcRr");
View Full Code Here

        assertScore(4, t, Location.W);
    }

    @Test
    public void circleWithCross() {
        Tile t;
        t = putTile(new Position(0,0), Rotation.R0, Expansion.BASIC, "Rr");
        putTile(new Position(-1,0), Rotation.R270, Expansion.BASIC, "Rr");
        putTile(new Position(0,1), Rotation.R90, Expansion.BASIC, "RrC");
        putTile(new Position(-1,1), Rotation.R0, Expansion.BASIC, "RRRR");
View Full Code Here

        assertScore(4, t, Location.W);
    }

    @Test
    public void inn() {
        Tile t;
        t = putTile(new Position(0,0), Rotation.R0, Expansion.BASIC, "RCr");
        putTile(new Position(-1,0), Rotation.R0, Expansion.BASIC, "RRRR");
        putTile(new Position(1,0), Rotation.R0, Expansion.INNS_AND_CATHEDRALS, "RFr.i");
        putTile(new Position(2,0), Rotation.R90, Expansion.BASIC, "LR");
View Full Code Here

        assertScore(8, t, Location.W);
    }

    @Test
    public void unfinishedInn() {
        Tile t;
        t = putTile(new Position(0,0), Rotation.R0, Expansion.BASIC, "RCr");
        putTile(new Position(-1,0), Rotation.R0, Expansion.BASIC, "RRRR");
        putTile(new Position(1,0), Rotation.R0, Expansion.INNS_AND_CATHEDRALS, "RFr.i");

        assertScore(0, t, Location.W);
View Full Code Here

        assertScore(0, t, Location.W);
    }

    @Test
    public void well() {
        Tile t;
        t = putTile(new Position(0,0), Rotation.R0, Expansion.ABBEY_AND_MAYOR, "Rrr");
        putTile(new Position(0,-1), Rotation.R0, Expansion.ABBEY_AND_MAYOR, "R");
        putTile(new Position(-1, 0), Rotation.R270, Expansion.ABBEY_AND_MAYOR, "R");
        putTile(new Position(1, 0), Rotation.R90, Expansion.ABBEY_AND_MAYOR, "R");
View Full Code Here

    assertEquals(expected, ctx.getPoints());
  }
 
  @Test
  public void single() {   
    Tile t;
    t = putTile(new Position(0,0), Rotation.R0, Expansion.BASIC, "L");   
   
    assertScore(1, t);   
  }
View Full Code Here

    assertScore(1, t);   
  }
 
  @Test
  public void incomplete() {   
    Tile t;
    t = putTile(new Position(0,0), Rotation.R0, Expansion.BASIC, "L");   
    putTile(new Position(1,0), Rotation.R0, Expansion.BASIC, "L");
    putTile(new Position(1,1), Rotation.R0, Expansion.BASIC, "L");
    putTile(new Position(0,1), Rotation.R0, Expansion.BASIC, "L");
    putTile(new Position(-1,0), Rotation.R0, Expansion.BASIC, "L");
View Full Code Here

TOP

Related Classes of com.jcloisterzone.board.Tile

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.