00001
00002
00003 #include "osl/search/analyzer/dotAnalyzer.h"
00004 #include "osl/search/analyzer/dotWriter.h"
00005 #include "osl/search/simpleHashTable.h"
00006 #include "osl/search/simpleHashRecord.h"
00007 #include "osl/hash/hashKey.h"
00008
00009 osl::search::analyzer::DotAnalyzer::
00010 DotAnalyzer(const SimpleHashTable& t, std::ostream& os)
00011 : table(t), writer(new DotWriter(os))
00012 {
00013 }
00014
00015 osl::search::analyzer::DotAnalyzer::
00016 ~DotAnalyzer()
00017 {
00018 }
00019
00020 void osl::search::analyzer::DotAnalyzer::
00021 resetWriter(LogWriter *new_writer)
00022 {
00023 writer.reset(new_writer);
00024 }
00025
00026 void osl::search::analyzer::DotAnalyzer::
00027 analyzeSequence(const HashKey& root, int limit,
00028 const Move *first, const Move *last)
00029 {
00030 const SimpleHashRecord *record = table.find(root);
00031 if (! record)
00032 return;
00033
00034 writer->showNode(root.turn(), record, limit,
00035 LogWriter::IMPORTANT);
00036 const SearchMoveSet& moves = record->moves();
00037 for (; first != last; ++first)
00038 {
00039 const SearchMove *move = moves.find(*first);
00040 if (! move)
00041 break;
00042 const SimpleHashRecord *next_record = move->record;
00043 if (! next_record)
00044 break;
00045 const MoveLogProb ml = move->moveLogProb();
00046 writer->showArc(record, next_record, ml, true);
00047 record = next_record;
00048 writer->showNode(ml.getMove().player(), record, limit, LogWriter::IMPORTANT);
00049 }
00050
00051 analyze(root, limit);
00052 }
00053
00054
00055
00056
00057
00058