Package com.jcloisterzone.board

Examples of com.jcloisterzone.board.Position


        int i = 0;
        for (Location side : Location.sides()) {
            if (side.intersect(completable.getLocation()) != null) {
                if (completable.getEdges()[i] == null) {
                    //side is open
                    Position p = completable.getTile().getPosition().add(side);
                    if (!openEdgesChanceToClose.containsKey(p)) {
                        OpenEdge edge = new OpenEdge();
                        edge.chanceToClose = aiPlayer.chanceToPlaceTile(game, p);
                        edge.feature = completable;
                        edge.location = side;
View Full Code Here


        return openEdgesChanceToClose;
    }

    private double updateCloisterChanceToClose(Cloister cloister) {
        double result = 1.0;
        Position p = cloister.getTile().getPosition();
        for (Position adjacent: p.addMulti(Position.ADJACENT_AND_DIAGONAL.values())) {
            result *= aiPlayer.chanceToPlaceTile(game, adjacent);
        }
        //for "1.6-compatibility" - make it already sense ?
        if (result > 0.85) return 0.85;
        return result;
View Full Code Here

        enemyPlayers = game.getAllPlayers().length - 1;
        myTurnsLeft = ((packSize-1) / (enemyPlayers+1)) + 1;
    }

    public double getPartialAfterTilePlacement(Game game, Tile tile) {
        Position pos = tile.getPosition();
        //return 0.001 * game.getBoard().getAdjacentAndDiagonalTiles(pos).size();
        return 0.001 * game.getBoard().getAdjacentTilesMap(pos).size(); //adjacent only is better
    }
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

    }

    protected double rankFairy(Game game) {
        if (!game.hasCapability(FairyCapability.class)) return 0;
        FairyCapability fc = game.getCapability(FairyCapability.class);
        Position fairyPos = fc.getFairyPosition();
        if (fairyPos == null) return 0;

        double rating = 0;

//    TODO more sophisticated rating
View Full Code Here

            if (towerCap != null) {
                for (Position towerPos : towerCap.getTowers()) {
                    int dangerDistance = 1 + game.getBoard().get(towerPos).getTower().getHeight();
                    towerDanger.add(towerPos);
                    for (int i = 1; i < dangerDistance; i++) {
                        towerDanger.add(towerPos.add(new Position(i, 0)));
                        towerDanger.add(towerPos.add(new Position(-i, 0)));
                        towerDanger.add(towerPos.add(new Position(0, i)));
                        towerDanger.add(towerPos.add(new Position(0, -i)));
                    }
                }
            }
        }
View Full Code Here

    }

    @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");

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

    }

    @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");

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

    }

    @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");

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

    }

    @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");

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

TOP

Related Classes of com.jcloisterzone.board.Position

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.