Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

FCSDebugDisplayInfo.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include <iostream.h>
00010 #include <stdlib.h>
00011 #include "FCSDebugDisplayInfo.h"
00012 #include "FCState.h"
00013 
00014 FCSDebugDisplayInfo::FCSDebugDisplayInfo()
00015 {
00016     m_DisplayDebug = false;
00017     m_DisplayDebugOptions = 0;
00018     m_NumberOfFreecells = 0;
00019     m_NumberOfStacks = 0;
00020     m_NumberOfDecks = 0;
00021     m_TalonType = FCS_TALON_NONE;
00022 
00023     Write.open("StateOutput.txt");
00024 }
00025 
00026 FCSDebugDisplayInfo::~FCSDebugDisplayInfo()
00027 {
00028     Write.close();
00029 }
00030 
00031 void FCSDebugDisplayInfo::Display(FCStateType StateType, int NumberOfIterations, 
00032                                   int Depth, FCSStateWithLocations* StateWithLocations, 
00033                                   int ParentNumberOfIterations, int StoredStates)
00034 {
00035     if (m_DisplayDebug)
00036     {
00037         Write << "Iteration: " << NumberOfIterations << endl;
00038         Write << "Depth: " << Depth << endl;
00039         Write << "Stored-States: " << StoredStates << endl << endl;
00040 
00041         if (m_DisplayDebugOptions & DEBUG_DISPLAY_PARENT_ITERATIONS)
00042             Write << "Parent Iteration: " << ParentNumberOfIterations << endl;
00043 
00044         if (m_DisplayDebugOptions & DEBUG_ITERATIVE_STATE_OUTPUT)
00045         {
00046             char* AsString = new char[STATE_STRING_SIZE];
00047             StateWithLocations->StateAsString(AsString, this);
00048             Write << AsString << endl << "---------------" << endl << endl << endl;
00049             delete [] AsString;
00050         }
00051 
00052         FCSCard* Card = NULL;
00053 
00054         int Valid = StateWithLocations->CheckStateValidity(m_NumberOfFreecells, m_NumberOfStacks,
00055                                                             m_NumberOfDecks, &Card, m_TalonType);
00056 
00057         if (Valid != 0)
00058         {
00059             char CardString[10];
00060 
00061             Card->Perl2User(CardString, (m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T), m_DisplayDebug);
00062 
00063             switch(Valid)
00064             {
00065             case 1:
00066                 cerr << "Error!  There's a missing card: " << CardString << endl;
00067                 break;
00068             case 2:
00069                 cerr << "Error!  There's an extra card: " << CardString << endl;
00070                 break;
00071             case 3:
00072                 cerr << "Error!  There's an empty slot in one of the stacks" << endl;
00073                 break;
00074             }
00075 
00076             exit(-1);
00077         }
00078     }
00079 }

Generated on Sat Nov 5 11:20:15 2005 for Cpp Freecell Solver by  doxygen 1.4.4