Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2873

Rule fires unexpectedly - not CE fails

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 5.2.0.CR1
    • 5.1.1.FINAL
    • drools-core
    • None

    Description

      The rule shown below fires, and then the code on the RHS prints "But cell ... matches" which is only possible when there is a Cell according to the constraints in the "not" CE. - The full Sudoku code is available.

      rule "column elimination"
      when
      not Setting()
      $i: Integer()

      1. occurs in a Cell
        $c: Cell( free contains $i, $cs: cellSqr, $cc: cellCol )
      2. but not in another cell of the same square and a different column
        not Cell( this != $c, free contains $i, cellSqr == $cs, cellCol != $cc )
        1. not ( $oc: Cell( this != $c )
        2. and
        3. eval( $oc.getFree().contains( $i ) &&
        4. $oc.getCellSqr().equals( $cs ) &&
        5. ! $oc.getCellCol().equals( $cc ) ) )
      1. but there is a cell in the same column and another square containing this value
        $cx: Cell( freeCount > 1, free contains $i, cellCol == $cc, cellSqr != $cs )
        then
      2. remove the value from that other cell
        System.out.println( "column elimination due to " + $c.posAsString() +
        ": remove " + $i + " from " + $cx.posAsString() );

      for( int iRow = 0; iRow < 9; iRow++ ){
      for( int iCol = 0; iCol < 9; iCol++ ){
      Cell cell = Sudoku.sudoku.cells[iRow][iCol];
      if( ! cell.equals( $c ) &&
      cell.getCellSqr().equals( $cs ) &&
      ! cell.getCellCol().equals( $cc ) &&
      cell.getFree().contains( $i ) )

      { System.out.println( "But cell " + cell.toString() + " matches!" ); }

      }
      }

      for( Cell c: $cs.getCells() )

      { System.out.print( c.posAsString() + ": " + c.getFree() + " cc="+c.getCellCol() + " cs="+c.getCellSqr() + "; " ); }


      System.out.println();

      modify( $cx )

      { blockValue( $i ) }

      end

      Attachments

        1. sudokubug.tgz
          27 kB
        2. sudokubug1.tgz
          28 kB
        3. sudokubug2.tgz
          31 kB
        4. sudokubug3.tgz
          36 kB

        Issue Links

          Activity

            People

              mproctor@redhat.com Mark Proctor
              laune Wolfgang Laun (Inactive)
              Archiver:
              rhn-support-ceverson Clark Everson

              Dates

                Created:
                Updated:
                Resolved:
                Archived:

                PagerDuty