/*

File BackjumpState.m

This state is used for backjumping search.  The state can keep track of a single nogood.

*/

#import <appkit/appkit.h>

#import "Backjump.h"


/* 行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行  */


@implementation BackjumpState

- squareClass			{	return [BackjumpSquare  class];		}
- wordClass				{	return [BackjumpWord  class];		}
- (BOOL) inNogood		{	return nogood;						}


/* 行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行行  */


- initPuzzle: (id) thePuzzle
{
	[super  initPuzzle: thePuzzle];
	nogoodWords = [[List  alloc]  init];
	nogood = NO;
	
	return self;
}


- free
{
	[nogoodWords  free];
	return [super  free];
}


- mustChange: (id) word
{
	[word  mark];
	[nogoodWords  addObject: word];
	nogood = YES;
	
	return self;
}


- isok
{
	if (nogood)
	{
		[nogoodWords  makeObjectsPerform: @selector(clear)];
		[nogoodWords  empty];
		nogood = NO;
	}
	
	return self;
}


@end