public WumpusKnowledgeBase(DPLL dpll,int caveXandYDimensions){
  super();
  this.dpll=dpll;
  this.caveXDimension=caveXandYDimensions;
  this.caveYDimension=caveXandYDimensions;
  tell(new ComplexSentence(Connective.NOT,newSymbol(PIT,1,1)));
  tell(new ComplexSentence(Connective.NOT,newSymbol(WUMPUS,1,1)));
  for (int y=1; y <= caveYDimension; y++) {
    for (int x=1; x <= caveXDimension; x++) {
      List<PropositionSymbol> pitsIn=new ArrayList<PropositionSymbol>();
      List<PropositionSymbol> wumpsIn=new ArrayList<PropositionSymbol>();
      if (x > 1) {
        pitsIn.add(newSymbol(PIT,x - 1,y));
        wumpsIn.add(newSymbol(WUMPUS,x - 1,y));
      }
      if (y < caveYDimension) {
        pitsIn.add(newSymbol(PIT,x,y + 1));
        wumpsIn.add(newSymbol(WUMPUS,x,y + 1));
      }
      if (x < caveXDimension) {
        pitsIn.add(newSymbol(PIT,x + 1,y));
        wumpsIn.add(newSymbol(WUMPUS,x + 1,y));
      }
      if (y > 1) {
        pitsIn.add(newSymbol(PIT,x,y - 1));
        wumpsIn.add(newSymbol(WUMPUS,x,y - 1));
      }
      tell(new ComplexSentence(newSymbol(BREEZE,x,y),Connective.BICONDITIONAL,Sentence.newDisjunction(pitsIn)));
      tell(new ComplexSentence(newSymbol(STENCH,x,y),Connective.BICONDITIONAL,Sentence.newDisjunction(wumpsIn)));
    }
  }
  List<PropositionSymbol> wumpsAtLeast=new ArrayList<PropositionSymbol>();
  for (int x=1; x <= caveXDimension; x++) {
    for (int y=1; y <= caveYDimension; y++) {
      wumpsAtLeast.add(newSymbol(WUMPUS,x,y));
    }
  }
  tell(Sentence.newDisjunction(wumpsAtLeast));
  int numRooms=(caveXDimension * caveYDimension);
  for (int i=0; i < numRooms; i++) {
    for (int j=i + 1; j < numRooms; j++) {
      tell(new ComplexSentence(Connective.OR,new ComplexSentence(Connective.NOT,newSymbol(WUMPUS,(i / caveXDimension) + 1,(i % caveYDimension) + 1)),new ComplexSentence(Connective.NOT,newSymbol(WUMPUS,(j / caveXDimension) + 1,(j % caveYDimension) + 1))));
    }
  }
}

public WumpusKnowledgeBase ( DPLL dpll , int caveXandYDimensions ) { super ( ) ; this . dpll = dpll ; this . caveXDimension = caveXandYDimensions ; this . caveYDimension = caveXandYDimensions ; tell ( new ComplexSentence ( Connective . NOT , newSymbol ( PIT , 1 , 1 ) ) ) ; tell ( new ComplexSentence ( Connective . NOT , newSymbol ( WUMPUS , 1 , 1 ) ) ) ; for ( int y = 1 ; y <= caveYDimension ; y ++ ) { for ( int x = 1 ; x <= caveXDimension ; x ++ ) { List < PropositionSymbol > pitsIn = new ArrayList < PropositionSymbol > ( ) ; List < PropositionSymbol > wumpsIn = new ArrayList < PropositionSymbol > ( ) ; if ( x > 1 ) { pitsIn . add ( newSymbol ( PIT , x - 1 , y ) ) ; wumpsIn . add ( newSymbol ( WUMPUS , x - 1 , y ) ) ; } if ( y < caveYDimension ) { pitsIn . add ( newSymbol ( PIT , x , y + 1 ) ) ; wumpsIn . add ( newSymbol ( WUMPUS , x , y + 1 ) ) ; } if ( x < caveXDimension ) { pitsIn . add ( newSymbol ( PIT , x + 1 , y ) ) ; wumpsIn . add ( newSymbol ( WUMPUS , x + 1 , y ) ) ; } if ( y > 1 ) { pitsIn . add ( newSymbol ( PIT , x , y - 1 ) ) ; wumpsIn . add ( newSymbol ( WUMPUS , x , y - 1 ) ) ; } tell ( new ComplexSentence ( newSymbol ( BREEZE , x , y ) , Connective . BICONDITIONAL , Sentence . newDisjunction ( pitsIn ) ) ) ; tell ( new ComplexSentence ( newSymbol ( STENCH , x , y ) , Connective . BICONDITIONAL , Sentence . newDisjunction ( wumpsIn ) ) ) ; } } List < PropositionSymbol > wumpsAtLeast = new ArrayList < PropositionSymbol > ( ) ; for ( int x = 1 ; x <= caveXDimension ; x ++ ) { for ( int y = 1 ; y <= caveYDimension ; y ++ ) { wumpsAtLeast . add ( newSymbol ( WUMPUS , x , y ) ) ; } } tell ( Sentence . newDisjunction ( wumpsAtLeast ) ) ; int numRooms = ( caveXDimension * caveYDimension ) ; for ( int i = 0 ; i < numRooms ; i ++ ) { for ( int j = i + 1 ; j < numRooms ; j ++ ) { tell ( new ComplexSentence ( Connective . OR , new ComplexSentence ( Connective . NOT , newSymbol ( WUMPUS , ( i / caveXDimension ) + 1 , ( i % caveYDimension ) + 1 ) ) , new ComplexSentence ( Connective . NOT , newSymbol ( WUMPUS , ( j / caveXDimension ) + 1 , ( j % caveYDimension ) + 1 ) ) ) ) ; } } }
create a knowledge base that contains the atemporal " wumpus physics " and temporal rules with time zero .
