Package org.drools.examples.conway

Examples of org.drools.examples.conway.Cell


    }

    private void toggleCellAt(int x,
                              int y)
    {
        Cell cell = getCellAtPoint( x,
                                    y );
        if ( cell != null )
        {
            if ( cell.getCellState( ) == CellState.LIVE )
            {
                cell.setCellState( CellState.DEAD );
            }
            else
            {
                cell.setCellState( CellState.LIVE );
            }
            repaint( );
        }
    }
View Full Code Here


    }

    private Cell getCellAtPoint(int x,
                                int y)
    {
        Cell cell = null;

        int column = x / cellSize;
        int row = y / cellSize;
        final int numberOfColumns = cellGrid.getNumberOfColumns( );
        final int numberOfRows = cellGrid.getNumberOfRows( );
View Full Code Here

        // draw populated cells
        for ( int row = 0; row < numberOfRows; row++ )
        {
            for ( int column = 0; column < numberOfColumns; column++ )
            {
                Cell cell = cellGrid.getCellAt( row,
                                                column );
                if ( cell.getCellState( ) == CellState.LIVE )
                {
                    g.drawImage( liveCellImage,
                                 column * cellSize,
                                 row * cellSize,
                                 this );
View Full Code Here

     *         condition, else <code>false</code>.
     *
     */
    public boolean isAllowed(Tuple tuple)
    {
        Cell cell = (Cell) tuple.get( cellDeclaration );
        return cell.getCellState() == CellState.DEAD;
    }
View Full Code Here

     *         condition, else <code>false</code>.
     *
     */
    public boolean isAllowed(Tuple tuple)
    {
        Cell cell = (Cell) tuple.get( cellDeclaration );
        int numberOfLiveNeighborsCellHas = cell.getNumberOfLiveNeighbors();
        boolean isAllowed = ( numberOfLiveNeighborsCellHas == 3 );
        return isAllowed;
    }
View Full Code Here

     *         condition, else <code>false</code>.
     *
     */
    public boolean isAllowed(Tuple tuple)
    {
        Cell cell = (Cell) tuple.get( cellDeclaration );
        int numberOfLiveNeighborsCellHas = cell.getNumberOfLiveNeighbors();
        boolean isAllowed = ( numberOfLiveNeighborsCellHas > 3 );
        return isAllowed;
    }
View Full Code Here

     *         condition, else <code>false</code>.
     *
     */
    public boolean isAllowed(Tuple tuple)
    {
        Cell cell = (Cell) tuple.get( cellDeclaration );
        return cell.getCellState() == CellState.LIVE;
    }
View Full Code Here

     * @param tuple
     *            The matching tuple.
     */
    public void invoke(Tuple tuple)
    {
        Cell cell = (Cell) tuple.get( cellDeclaration );
        cell.queueNextCellState( CellState.LIVE );
    }
View Full Code Here

     * @param tuple
     *            The matching tuple.
     */
    public void invoke(Tuple tuple)
    {
        Cell cell = (Cell) tuple.get( cellDeclaration );
        cell.queueNextCellState( CellState.DEAD );
    }
View Full Code Here

     *         condition, else <code>false</code>.
     *
     */
    public boolean isAllowed(Tuple tuple)
    {
        Cell cell = (Cell) tuple.get( cellDeclaration );
        int numberOfLiveNeighborsCellHas = cell.getNumberOfLiveNeighbors();
        boolean isAllowed = ( numberOfLiveNeighborsCellHas < 2 );
        return isAllowed;
    }
View Full Code Here

TOP

Related Classes of org.drools.examples.conway.Cell

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.