src/demo/Maze.java
private void updateState() {
        Matrix state = new DMatrix(stateSize, 1);
        Iterator<Maze.MazeAgent> iterator = mazeAgentHistory.iterator();
        int index = 0;
        while (iterator.hasNext()) {
            MazeAgent mazeAgent = iterator.next();
            if (mazeAgent.action != -1) {
                state.setValue(index + mazeAgent.action, 0, -1);
            }
            index += 4;
        }
        Cell mazeCell = maze[mazeAgentCurrent.x][mazeAgentCurrent.y];
        state.setValue(4 * agentHistorySize, 0, mazeCell.isConnected(0) ? -1 : 0);
        state.setValue(4 * agentHistorySize + 1, 0, mazeCell.isConnected(1) ? -1 : 0);
        state.setValue(4 * agentHistorySize + 2, 0, mazeCell.isConnected(2) ? -1 : 0);
        state.setValue(4 * agentHistorySize + 3, 0, mazeCell.isConnected(3) ? -1 : 0);

        HashSet<Integer> availableActions = new HashSet<>();
        Cell cell = maze[mazeAgentCurrent.x][mazeAgentCurrent.y];
        for (int action = 0; action < cell.neighbors.length; action++) {
            Neighbor neighbor = cell.neighbors[action];
            if (neighbor != null) if (neighbor.connected) availableActions.add(action);
        }
        environmentState = new EnvironmentState(++episodeID, 1, state, availableActions);
    }
/**
     * Updates state based on state of environment.
     *
     */
Updates state based on state of environment.
Updates state based on state of environment .
private void updateState() {
        Matrix state = new DMatrix(stateSize, 1);
        Iterator<Maze.MazeAgent> iterator = mazeAgentHistory.iterator();
        int index = 0;
        while (iterator.hasNext()) {
            MazeAgent mazeAgent = iterator.next();
            if (mazeAgent.action != -1) {
                state.setValue(index + mazeAgent.action, 0, -1);
            }
            index += 4;
        }
        Cell mazeCell = maze[mazeAgentCurrent.x][mazeAgentCurrent.y];
        state.setValue(4 * agentHistorySize, 0, mazeCell.isConnected(0) ? -1 : 0);
        state.setValue(4 * agentHistorySize + 1, 0, mazeCell.isConnected(1) ? -1 : 0);
        state.setValue(4 * agentHistorySize + 2, 0, mazeCell.isConnected(2) ? -1 : 0);
        state.setValue(4 * agentHistorySize + 3, 0, mazeCell.isConnected(3) ? -1 : 0);
        HashSet<Integer> availableActions = new HashSet<>();
        Cell cell = maze[mazeAgentCurrent.x][mazeAgentCurrent.y];
        for (int action = 0; action < cell.neighbors.length; action++) {
            Neighbor neighbor = cell.neighbors[action];
            if (neighbor != null) if (neighbor.connected) availableActions.add(action);
        }
        environmentState = new EnvironmentState(++episodeID, 1, state, availableActions);
    }
private void updateState ( ) { Matrix state = new DMatrix ( stateSize , 1 ) ; Iterator < Maze . MazeAgent > iterator = mazeAgentHistory . iterator ( ) ; int index = 0 ; while ( iterator . hasNext ( ) ) { MazeAgent mazeAgent = iterator . next ( ) ; if ( mazeAgent . action != - 1 ) { state . setValue ( index + mazeAgent . action , 0 , - 1 ) ; } index += 4 ; } Cell mazeCell = maze [ mazeAgentCurrent . x ] [ mazeAgentCurrent . y ] ; state . setValue ( 4 * agentHistorySize , 0 , mazeCell . isConnected ( 0 ) ? - 1 : 0 ) ; state . setValue ( 4 * agentHistorySize + 1 , 0 , mazeCell . isConnected ( 1 ) ? - 1 : 0 ) ; state . setValue ( 4 * agentHistorySize + 2 , 0 , mazeCell . isConnected ( 2 ) ? - 1 : 0 ) ; state . setValue ( 4 * agentHistorySize + 3 , 0 , mazeCell . isConnected ( 3 ) ? - 1 : 0 ) ; HashSet < Integer > availableActions = new HashSet < > ( ) ; Cell cell = maze [ mazeAgentCurrent . x ] [ mazeAgentCurrent . y ] ; for ( int action = 0 ; action < cell . neighbors . length ; action ++ ) { Neighbor neighbor = cell . neighbors [ action ] ; if ( neighbor != null ) if ( neighbor . connected ) availableActions . add ( action ) ; } environmentState = new EnvironmentState ( ++ episodeID , 1 , state , availableActions ) ; }
Updates state based on state of environment.
Updates state based on state of environment .