예제 #1
0
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)));
    }
}
예제 #2
0
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();
   }
}
예제 #3
0
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);
}
예제 #4
0
Befunge::FieldPointer::FieldPointer(int xsize, int ysize)
{
    pos = CoordPair(xsize, ysize);
    setDirection(EAST);
}
예제 #5
0
Befunge::FieldPointer::FieldPointer()
{
    pos = CoordPair(80, 24);
    setDirection(EAST);
}