home *** CD-ROM | disk | FTP | other *** search
- /*
-
- 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