Package net.bytten.metazelda

Examples of net.bytten.metazelda.Symbol


                constraints.initialRooms());
        assert possibleEntries.size() > 0;
        id = possibleEntries.get(random.nextInt(possibleEntries.size()));
       
        Room entry = new Room(id, constraints.getCoords(id), null,
                new Symbol(Symbol.START), new Condition());
        dungeon.add(entry);
       
        levels.addRoom(0, entry);
    }
View Full Code Here


    protected void placeRooms(KeyLevelRoomMapping levels, int roomsPerLock)
            throws RetryException, OutOfRoomsException {
       
        // keyLevel: the number of keys required to get to the new room
        int keyLevel = 0;
        Symbol latestKey = null;
        // condition that must hold true for the player to reach the new room
        // (the set of keys they must have).
        Condition cond = new Condition();
       
        int usableKeys = constraints.getMaxKeys();
        if (isBossRoomLocked())
            usableKeys -= 1;
       
        // Loop to place rooms and link them
        while (dungeon.roomCount() < constraints.getMaxRooms()) {
           
            boolean doLock = false;
           
            // Decide whether we need to place a new lock
            // (Don't place the last lock, since that's reserved for the boss)
            if (levels.getRooms(keyLevel).size() >= roomsPerLock &&
                    keyLevel < usableKeys) {
                latestKey = new Symbol(keyLevel++);
                cond = cond.and(latestKey);
                doLock = true;
            }
           
            // Find an existing room with a free edge:
View Full Code Here

     */
    protected void placeBossGoalRooms(KeyLevelRoomMapping levels)
            throws RetryException {
        List<Room> possibleGoalRooms = new ArrayList<Room>(dungeon.roomCount());
       
        Symbol goalSym = new Symbol(Symbol.GOAL),
               bossSym = new Symbol(Symbol.BOSS);
       
        for (Room room: dungeon.getRooms()) {
            if (room.getChildren().size() > 0 || room.getItem() != null)
                continue;
            Room parent = room.getParent();
            if (parent == null || parent.getChildren().size() != 1 ||
                    room.getItem() != null ||
                    !parent.getPrecond().implies(room.getPrecond()))
                continue;
            if (isGenerateGoal()) {
                if (!constraints.roomCanFitItem(room.id, goalSym) ||
                        !constraints.roomCanFitItem(parent.id, bossSym))
                    continue;
            } else {
                if (!constraints.roomCanFitItem(room.id, bossSym))
                    continue;
            }
            possibleGoalRooms.add(room);
        }
       
        if (possibleGoalRooms.size() == 0) throw new RetryException();
       
        Room goalRoom = possibleGoalRooms.get(random.nextInt(
                possibleGoalRooms.size())),
             bossRoom = goalRoom.getParent();
       
        if (!isGenerateGoal()) {
            bossRoom = goalRoom;
            goalRoom = null;
        }
       
        if (goalRoom != null) goalRoom.setItem(goalSym);
        bossRoom.setItem(bossSym);
       
        if (isBossRoomLocked()) {
            int oldKeyLevel = bossRoom.getPrecond().getKeyLevel(),
                newKeyLevel = Math.min(levels.keyCount(), constraints.getMaxKeys());
           
            List<Room> oklRooms = levels.getRooms(oldKeyLevel);
            if (goalRoom != null) oklRooms.remove(goalRoom);
            oklRooms.remove(bossRoom);
           
            if (goalRoom != null) levels.addRoom(newKeyLevel, goalRoom);
            levels.addRoom(newKeyLevel, bossRoom);
           
            Symbol bossKey = new Symbol(newKeyLevel-1);
            Condition precond = bossRoom.getPrecond().and(bossKey);
            bossRoom.setPrecond(precond);
            if (goalRoom != null) goalRoom.setPrecond(precond);
           
            if (newKeyLevel == 0) {
View Full Code Here

            if (baseRoom == null) throw new RetryException();
            Condition baseRoomCond = baseRoom.getPrecond();
           
            removeDescendantsFromList(rooms, baseRoom);
           
            Symbol switchSym = new Symbol(Symbol.SWITCH);
           
            Room switchRoom = null;
            for (Room room: rooms) {
                if (room.getItem() == null &&
                        baseRoomCond.implies(room.getPrecond()) &&
View Full Code Here

                            constraints.edgeGraphifyProbability(room.id, nextRoom.id))
                        continue;
                   
                    dungeon.link(room, nextRoom);
                } else {
                    Symbol difference = room.getPrecond().singleSymbolDifference(
                            nextRoom.getPrecond());
                    if (difference == null || (!difference.isSwitchState() &&
                            random.nextDouble() >=
                                constraints.edgeGraphifyProbability(room.id, nextRoom.id)))
                        continue;
                    dungeon.link(room, nextRoom, difference);
                }
View Full Code Here

            // which means the shuffling we just did is still useful.
            Collections.sort(rooms, INTENSITY_COMPARATOR);
            // Alternatively, use the EDGE_COUNT_COMPARATOR to put keys at
            // 'dead end' rooms.
           
            Symbol keySym = new Symbol(key);
           
            boolean placedKey = false;
            for (Room room: rooms) {
                if (room.getItem() == null && constraints.roomCanFitItem(room.id, keySym)) {
                    room.setItem(keySym);
View Full Code Here

        for (int i = 0; i < constraints.getMaxKeys(); ++i) {
            keyRooms.add(null);
        }
        for (Room room: dungeon.getRooms()) {
            if (room.getItem() == null) continue;
            Symbol item = room.getItem();
            if (item.getValue() >= 0 && item.getValue() < keyRooms.size())
                keyRooms.set(item.getValue(), room);
        }
        // for N >= 0: keyRooms[N] = location of key N
       
        Room current = dungeon.findStart(),
                goal = dungeon.findGoal();
View Full Code Here

TOP

Related Classes of net.bytten.metazelda.Symbol

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.