<commit_before>package edu.rpi.phil.legup.puzzles.nurikabe;

import javax.swing.ImageIcon;

import edu.rpi.phil.legup.BoardState;
import edu.rpi.phil.legup.Contradiction;

public class ContradictionNoNumber extends Contradiction
{
    private static final long serialVersionUID = 16944369L;

	 ContradictionNoNumber()
	 {
		setName("No Number");
		description = "All enclosed white regions must have a number.";
		image = new ImageIcon("images/nurikabe/contradictions/NoNumber.png");
	 }

	public String getImageName()
	{
		return "images/nurikabe/contradictions/NoNumber.png";
	}

	 /**
     * Checks if the contradiction was applied correctly to this board state
     *
     * @param state The board state
     * @return null if the contradiction was applied correctly, the error String otherwise
     */
    public String checkContradictionRaw(BoardState state)
    {
    	int height = state.getHeight();
    	int width = state.getWidth();

//    	false = not checked, true = checked
    	boolean[][] neighbors = new boolean[height][width];
    	for(int x = 0; x < width; ++x)
    	{
    		for(int y = 0; y < height; ++y)
    		{
    			if(state.getCellContents(x,y) == Nurikabe.CELL_BLACK)
    			{
    				neighbors[y][x] = true;
    			}
    		}
    	}

    	for(int x = 0; x < width; ++x)
    	{
    		for(int y = 0; y < height; ++y)
    		{
    			if(!neighbors[y][x])
    			{
    				if(loopConnected(neighbors, state,x,y,width,height) == 0)
    					return null;
    			}
    		}
    	}

    	return "No regions without a number.";
    }

    private int loopConnected(boolean[][] neighbors,BoardState boardState, int x, int y, int width, int height)
    {
    	int numcount = 0;
    	if(boardState.getCellContents(x,y) > 10)
    		++numcount;
    	// if(boardState.getCellContents(x,y) == Nurikabe.CELL_UNKNOWN)
    	// 	++numcount;
    	neighbors[y][x] = true;
    	if(x+1 < width)
    	{
    		if(!neighbors[y][x+1])
    			numcount += loopConnected(neighbors, boardState, x+1, y, width, height);
    	}
    	if(x-1 >= 0)
    	{
    		if(!neighbors[y][x-1])
    			numcount += loopConnected(neighbors, boardState, x-1, y, width, height);
    	}
    	if(y+1 < height)
    	{
    		if(!neighbors[y+1][x])
    			numcount += loopConnected(neighbors, boardState, x, y+1, width, height);
    	}
    	if(y-1 >= 0)
    	{
    		if(!neighbors[y-1][x])
    			numcount += loopConnected(neighbors, boardState, x, y-1, width, height);
    	}
    	return numcount;
    }
}
<commit_msg>Fixed ContradictionNoNumber to work with unknowns<commit_after>package edu.rpi.phil.legup.puzzles.nurikabe;

import javax.swing.ImageIcon;

import edu.rpi.phil.legup.BoardState;
import edu.rpi.phil.legup.Contradiction;
import edu.rpi.phil.legup.ConnectedRegions;
import java.util.List;
import java.util.Set;
import java.awt.Point;

public class ContradictionNoNumber extends Contradiction
{
    private static final long serialVersionUID = 16944369L;

	 ContradictionNoNumber()
	 {
		setName("No Number");
		description = "All enclosed white regions must have a number.";
		image = new ImageIcon("images/nurikabe/contradictions/NoNumber.png");
	 }

	public String getImageName()
	{
		return "images/nurikabe/contradictions/NoNumber.png";
	}

	 /**
     * Checks if the contradiction was applied correctly to this board state
     *
     * @param state The board state
     * @return null if the contradiction was applied correctly, the error String otherwise
     */
    public String checkContradictionRaw(BoardState state)
    {
    	int height = state.getHeight();
    	int width = state.getWidth();
      int[][] cells = new int[height][width];

      for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
          cells[y][x] = state.getCellContents(x, y);
        }
      }
      List<Set<Point>> regions = ConnectedRegions.getConnectedRegions(Nurikabe.CELL_BLACK, cells, width, height);
      for (Set<Point> region : regions)
      {
        if (!ConnectedRegions.regionContains(Nurikabe.CELL_WHITE, cells, region)) continue;
        boolean haveNumber = false;
        for (Point p : region)
        {
          if (state.getCellContents(p.x, p.y) > 10)
          {
            haveNumber = true;
            break;
          }
        }
        if (!haveNumber) return null;
      }

      return "No white regions (contains >1 white cell) without a number.";
    }
}

{'fraction_non_alphanumeric': 0.11815181518151815, 'fraction_numerical': 0.00946094609460946, 'mean_word_length': 2.3674074074074074, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7392075', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1529, 'n_words': 347}