void BoardModel::getPath(int startX, int startY, int endX, int endY) { // Log("Threaded pathfinding - from (%d, %d) to (%d, %d)", startX, startY, endX, endY); m_startGrid = GridInfo(startX, startY); m_endGrid = GridInfo(endX, endY); m_thread = GameThread::createThread(this); m_thread->start(); }
// Action_Grid::Init() Action::RetType Action_Grid::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { debug_ = debugIn; nframes_ = 0; // Get output filename std::string filename = actionArgs.GetStringKey("out"); // Get grid options grid_ = GridInit( "GRID", actionArgs, init.DSL() ); if (grid_ == 0) return Action::ERR; # ifdef MPI if (ParallelGridInit(init.TrajComm(), grid_)) return Action::ERR; # endif // Get extra options max_ = actionArgs.getKeyDouble("max", 0.80); madura_ = actionArgs.getKeyDouble("madura", 0); smooth_ = actionArgs.getKeyDouble("smoothdensity", 0); invert_ = actionArgs.hasKey("invert"); pdbfile_ = init.DFL().AddCpptrajFile(actionArgs.GetStringKey("pdb"),"Grid PDB",DataFileList::PDB,true); density_ = actionArgs.getKeyDouble("density",0.033456); if (actionArgs.hasKey("normframe")) normalize_ = TO_FRAME; else if (actionArgs.hasKey("normdensity")) normalize_ = TO_DENSITY; else normalize_ = NONE; if (normalize_ != NONE && (smooth_ > 0.0 || madura_ > 0.0)) { mprinterr("Error: Normalize options are not compatible with smoothdensity/madura options.\n"); init.DSL().RemoveSet( grid_ ); return Action::ERR; } // Get mask std::string maskexpr = actionArgs.GetMaskNext(); if (maskexpr.empty()) { mprinterr("Error: GRID: No mask specified.\n"); init.DSL().RemoveSet( grid_ ); return Action::ERR; } mask_.SetMaskString(maskexpr); // Setup output file // For backwards compat., if no 'out' assume next string is filename if (filename.empty() && actionArgs.Nargs() > 1 && !actionArgs.Marked(1)) filename = actionArgs.GetStringNext(); DataFile* outfile = init.DFL().AddDataFile(filename, actionArgs); if (outfile != 0) outfile->AddDataSet((DataSet*)grid_); // Info mprintf(" GRID:\n"); GridInfo( *grid_ ); if (outfile != 0) mprintf("\tGrid will be printed to file %s\n", outfile->DataFilename().full()); mprintf("\tGrid data set: '%s'\n", grid_->legend()); mprintf("\tMask expression: [%s]\n",mask_.MaskString()); if (pdbfile_ != 0) mprintf("\tPseudo-PDB will be printed to %s\n", pdbfile_->Filename().full()); if (normalize_ == TO_FRAME) mprintf("\tGrid will be normalized by number of frames.\n"); else if (normalize_ == TO_DENSITY) mprintf("\tGrid will be normalized to a density of %g molecules/Ang^3.\n", density_); // TODO: print extra options return Action::OK; }
GridInfo BoardModel::findGrid(const Ball* ball) const { for(int j = 0; j < COUNT; ++j) { for(int i = 0; i < COUNT; ++i) { if(m_grids[i][j].ball.get() == ball) { return GridInfo(i, j); } } } Log("Wrong pointer supplied - %p", ball); Log("Ball's color - %d", ball->getBallColor()); assert(!"Wrong pointer supplied!"); return GridInfo(-1, -1); }
const BoardModel::GridInfoContainer& BoardModel::getOccupiedGrids() const { static GridInfoContainer occupied; occupied.clear(); for(int j = 0; j < COUNT; ++j) { for(int i = 0; i < COUNT; ++i) { if(m_grids[i][j].ball != null) { occupied.push_back(GridInfo(i, j)); } } } return occupied; }
const BoardModel::GridInfoContainer& BoardModel::getFreeGrids() const { static GridInfoContainer empty; empty.clear(); for(int j = 0; j < COUNT; ++j) { for(int i = 0; i < COUNT; ++i) { if(m_grids[i][j].ball == null) { empty.push_back(GridInfo(i, j)); } } } return empty; }
// Action_GridFreeEnergy::init() Action::RetType Action_GridFreeEnergy::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { // Get output filename DataFile* outfile = init.DFL().AddDataFile(actionArgs.GetStringNext(), actionArgs); if (outfile == 0) { mprinterr("Error: GridFreeEnergy: no output filename specified.\n"); return Action::ERR; } // Get grid options (<nx> <dx> <ny> <dy> <nz> <dz> [box|origin] [negative]) grid_ = GridInit( "GridFreeEnergy", actionArgs, init.DSL() ); if (grid_ == 0) return Action::ERR; # ifdef MPI if (ParallelGridInit(init.TrajComm(), grid_)) return Action::ERR; # endif //grid_.PrintXplor( filename_, "", "REMARKS Change in Free energy from bulk solvent with bin normalisation of " + integerToString(currentLargestVoxelOccupancyCount) ); // Get mask std::string maskexpr = actionArgs.GetMaskNext(); if (maskexpr.empty()) { mprinterr("Error: GridFreeEnergy: No mask specified.\n"); init.DSL().RemoveSet( grid_ ); return Action::ERR; } mask_.SetMaskString(maskexpr); // Get extra args tempInKevin_ = actionArgs.getKeyDouble("temp", 293.0); outfile->AddDataSet( grid_ ); // Info mprintf("Warning: DNAIONTRACKER is experimental code!\n"); mprintf(" GridFreeEnergy\n"); GridInfo( *grid_ ); mprintf("\tGrid will be printed to file %s\n",outfile->DataFilename().full()); mprintf("\tMask expression: [%s]\n",mask_.MaskString()); mprintf("\tTemp is : %f K\n",tempInKevin_); // Allocate grid //if (GridAllocate()) return 1; return Action::OK; }