Package pr.lib

Examples of pr.lib.Vec


        int lastRow = this.getWidth()+startRow;
        int lastCol = this.getHeight()+startCol;
        Iterator<Vec> iterator = new VecIterator(startRow, lastRow, startCol, lastCol);
       
        while(iterator.hasNext()) {
            Vec p = iterator.next();
            BlockType t = this.getBlockFor(p);

            if (t != null) {
                world.makeBlock(t, p);
            }
View Full Code Here


        }

        @Override
        public Vec next() {

            Vec v = new Vec(col, row);
            //Debug.log(v.toString());
            col++;
            if (col > endCol) {
                col = startCol;
                row++;
View Full Code Here

   
    public boolean move(Dir d) {
        if (!moveFreqLimiter.Can()) {
            return false;
        }
        Vec tp = p.InDirection(d);
        if (world.get(tp) == null) {
            boolean moveSucceeded = moveTo(p.InDirection(d));
            if (moveSucceeded) {
                moveFreqLimiter.Do();
            }
View Full Code Here

    public boolean moveBackwards() {
        return move(d.Back);
    }

    public boolean build() {
        Vec tp = posInFront();
        if (world.get(tp) != null) {
            return false;
        }
        world.makeBlock(BlockType.IRON, tp);
        return true;
View Full Code Here

    }

    @Override
    public void gen(World world) {
        for (int x = 0; x < width; x++) {
            world.makeBlock(blockType, southWestCorner.plus(new Vec(x, 0)));
            world.makeBlock(blockType, southWestCorner.plus(new Vec(x, width - 1)));
        }
        for (int y = 0; y < height; y++) {
            world.makeBlock(blockType, southWestCorner.plus(new Vec(0, y)));
            world.makeBlock(blockType, southWestCorner.plus(new Vec(height - 1, y)));
        }
    }
View Full Code Here

public class BoundingBox implements IGen{

    public final BlockType blockType = BlockType.BEDROCK;
    public void gen(World w) {
        for (int x = -1; x <= w.width; x++) {
            w.makeBlock(blockType, new Vec(x, -1));
            w.makeBlock(blockType, new Vec(x, w.width));
        }
        for (int y = -1; y <= w.height; y++) {
            w.makeBlock(blockType, new Vec(-1, y));
            w.makeBlock(blockType, new Vec(w.height, y));
        }
    }
View Full Code Here

        set(p);
        for (int i = 0; i < steps; i++) {
            int[] pSpotsScores = new int[4];
            for (int j = 0; j < 4; j++) {
                Dir pd = d.turn(Turn.values()[j]);
                Vec pHallSpot = p.InDirection(pd);
                Vec pSpot = pHallSpot.InDirection(pd);

                if (pSpot.distanceTo(world.midpoint) >= world.width / 2) {
                    //Debug.log(pSpot+" " + j+ " is out of bounds! ");
                    pSpotsScores[j] = 0;
                    continue;
                }
View Full Code Here

    }

    private void make(long seed) {
        rng.setSeed(seed);
        map = new boolean[world.height][world.width];
        Vec start = world.midpoint;
        int steps = world.width * world.height / (4 * 6);

        int baseScore = 10;
        int noRepeatScore = 10000;
        int noBackTrackScore = -5;
        int noTurnScore = 20;
        int radius = world.width / 2 - 2;

        randomWalk(start, Dir.East, steps, baseScore, noRepeatScore, noBackTrackScore, noTurnScore);

        for (Dir d : Dir.dirs) {
            Vec startPoint = world.midpoint.InDirection(d, d == Dir.North ? radius + 2 : radius);
            randomWalk(startPoint, Dir.East, steps, baseScore, noRepeatScore, noBackTrackScore, noTurnScore);
        }
    }
View Full Code Here

        length = astar(map, world.midpoint, world.getGoal());
        world.setMessage(length + "," + seed + "," + score());

        Iterator<Vec> vi = world.iterator();
        while (vi.hasNext()) {
            Vec p = vi.next();
            if (!get(p)) {
                world.makeBlock(blockType, p);
            }
        }
    }
View Full Code Here

TOP

Related Classes of pr.lib.Vec

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.