const Board Board::Empty() {

    Board board;

    uint counter = 0;
    for (uint i = 0; i < Dim::actual_field_count; ++i)
        board.rev_map[i] = -1;
    for (uint i = 1; i <= Dim::board_size; ++i) {
        for (uint j = 1; j <= Dim::board_size; ++j) {
            signed int field = Dim::OfPos(i, j);
            board.field_map[counter] = field;
            board.rev_map[field] = counter++;
        }
    }

    for (uint i = 0; i < Dim::actual_field_count; ++i)
        board.board[i] = board_empty;
    for (uint i = 1; i <= Dim::board_size; ++i) {
        board.board[Dim::OfPos(i, 0)] = ToFirst(root_up);
        board.board[Dim::OfPos(i, Dim::board_size + 1)] = ToFirst(root_down);
        board.board[Dim::OfPos(0, i)] = ToSecond(root_left);
        board.board[Dim::OfPos(Dim::board_size + 1, i)] = ToSecond(root_right);
    }

    board.ClearShortestPathsStats();

    return board;
}
示例#2
0
//_____________________________________________
void KVLifeTimeTable::Initialize()
{

    TString dfile;
    dfile.Form("%s.DataFile",GetName());
    TString cl_path;
    if( !KVBase::SearchKVFile(gEnv->GetValue(dfile.Data(),""),cl_path,"data") ) {
        Error("Initialize","No file found for %s",GetName());
        return;
    }
    else {
        //Info("Initialize","%s will be read",gEnv->GetValue(dfile.Data(),""));
    }
    SetTitle(gEnv->GetValue(dfile.Data(),""));

    Int_t ntot=0;
    nucMap = new TMap(50,2);
    KVFileReader* fr = new KVFileReader();
    fr->OpenFileToRead(cl_path.Data());

    //Premier passage
    while (fr->IsOK()) {

        fr->ReadLine(" ");
        if (fr->GetNparRead()==0) break;
        else if (fr->GetReadPar(0).BeginsWith("//")) {

            kcomments+=fr->GetCurrentLine();
            kcomments+="\n";

        }
        else {
            Int_t zz = fr->GetIntReadPar(0);
            Int_t aa = fr->GetIntReadPar(1);
            GiveIndexToNucleus(zz,aa,ntot);
            ntot+=1;
        }
    }

    if ( !fr->PreparForReadingAgain() ) return;

    //Info("Initialize","Set up map for %d nuclei", ntot);
    CreateTable(ntot);

    KVLifeTime* lf = 0;
    ntot=0;
    while (fr->IsOK()) {

        fr->ReadLine(" ");
        if (fr->GetCurrentLine().IsNull()) {
            break;
        }
        else if (fr->GetNparRead()==0) {
            break;
        }
        else if (fr->GetReadPar(0).BeginsWith("//")) { }
        else {
            Double_t val = fr->GetDoubleReadPar(2);

            CreateElement(ntot);
            lf = (KVLifeTime* )GetCurrent();

            if (fr->GetNparRead()>3) {
                TString unit = fr->GetReadPar(3);
                if ( unit.EndsWith("eV") ) {
                    lf->SetResonnance(kTRUE);
                    val *= ToMeV(unit);
                }
                else {
                    lf->SetResonnance(kFALSE);
                    val *= ToSecond(unit);
                }
                if (fr->GetNparRead()>4) {
                    Int_t meas = fr->GetReadPar(4).Atoi();
                    lf->SetMeasured(meas);
                }
                else {
                    if (ntot==0) InfoOnMeasured();
                }
            }
            lf->SetValue(val);

            ntot+=1;
        }

    }

    //Info("Initialize","table initialised correctly for %d nuclei", ntot);
    fr->CloseFile();
    delete fr;

}