void buildCoordPairSet(std::string filename, std::vector< std::pair<int, CoordPair> > &v){ std::ifstream file(filename.c_str(), std::ifstream::in); int i, x, y; while(file >> i >> x >> y){ v.push_back(std::pair<int, CoordPair>(i, CoordPair((double)x, (double)y))); } }
CoordPair CoordPair::fromString(const std::string& str) { if(str.length()==4) { CoordPair cpair; cpair.from = ChessCoord::fromString(str.substr(0, 2)); if(cpair.from==ChessCoord()) return CoordPair(); cpair.to = ChessCoord::fromString(str.substr(2)); if(cpair.to==ChessCoord()) return CoordPair(); return cpair; } else { return CoordPair(); } }
ChessMove ChessMove::fromString(const std::string& str) { if(str.length()<4) { return ChessMove(); } PieceType promotion = ptNone; if(str.length()>4) { ChessPiece p = ChessPiece::fromChar(str[4]); switch(p.type()) { case ptQueen: case ptRook: case ptBishop: case ptKnight: promotion = p.type(); break; } } CoordPair cpair = CoordPair::fromString(str.substr(0, 4)); if(cpair==CoordPair()) return ChessMove(); return ChessMove(cpair, promotion); }
Befunge::FieldPointer::FieldPointer(int xsize, int ysize) { pos = CoordPair(xsize, ysize); setDirection(EAST); }
Befunge::FieldPointer::FieldPointer() { pos = CoordPair(80, 24); setDirection(EAST); }