Move MakeMoveFromUciString(Position &position, const std::string &moveString) { const Square from = MakeSquare(RANK_1 - (moveString[1] - '1'), moveString[0] - 'a'); const Square to = MakeSquare(RANK_1 - (moveString[3] - '1'), moveString[2] - 'a'); if (moveString.length() == 5) { int promotionType; switch (tolower(moveString[4])) { case 'n': promotionType = PromotionTypeKnight; break; case 'b': promotionType = PromotionTypeBishop; break; case 'r': promotionType = PromotionTypeRook; break; case 'q': promotionType = PromotionTypeQueen; break; } return GeneratePromotionMove(from, to, promotionType); } Move moves[256]; int moveCount = GenerateLegalMoves(position, moves); for (int i = 0; i < moveCount; i++) { if (GetFrom(moves[i]) == from && GetTo(moves[i]) == to) { return moves[i]; } } ASSERT(false); return 0; }
wxString wxEmailMessage::PayLoad() const { wxString payload; payload << "Date: " << wxDateTime::Now().Format() << "\r\n"; payload << "To: " << GetTo() << "\r\n"; payload << "From: " << GetFrom() << "\r\n"; payload << "Cc: \r\n"; payload << "Message-ID: " << GenerateID() << "\r\n"; payload << "Subject: " << GetSubject() << "\r\n"; // Sending attachment payload << "Content-Type: multipart/mixed; boundary=\"" << BOUNDRY_LINE << "\"\r\n"; payload << "Mime-version: 1.0\r\n"; payload << "\r\n"; payload << "This is a multi-part message in MIME format. \r\n"; // Message body if(!GetMessage().IsEmpty()) { payload << "\r\n--" << BOUNDRY_LINE << "\r\n"; payload << "Content-Type: text/plain; charset=\"us-ascii\"\r\n"; payload << "Content-Transfer-Encoding: quoted-printable \r\n"; payload << "\r\n"; payload << GetMessage() << "\r\n"; } if(!m_attachements.IsEmpty()) { for(size_t i = 0; i < m_attachements.size(); ++i) { DoAddAttachment(m_attachements.Item(i), payload); } } payload << "\r\n"; return payload; }
std::string GetMoveUci(const Move move) { std::string result; result += GetSquareSAN(GetFrom(move)); result += GetSquareSAN(GetTo(move)); if (GetMoveType(move) == MoveTypePromotion) { switch (GetPromotionMoveType(move)) { case KNIGHT: result += "n"; break; case BISHOP: result += "b"; break; case ROOK: result += "r"; break; case QUEEN: result += "q"; break; } } return result; }
void ribi::cmap::QtTestQtEdgeDialog::on_button_load_clicked() noexcept { const int index = ui->box_test_index->value(); assert(m_from); assert(m_to); assert(index >= 0); assert(index < QtEdgeFactory().GetNumberOfTests()); const auto qtedge = QtEdgeFactory().GetTest(index,m_from,m_to); assert(m_from->flags() & QGraphicsItem::ItemIsMovable); assert(m_from->flags() & QGraphicsItem::ItemIsSelectable); assert(m_to->flags() & QGraphicsItem::ItemIsMovable); assert(m_to->flags() & QGraphicsItem::ItemIsSelectable); SetQtEdge(qtedge); assert(qtedge == m_qtedge_dialog->GetQtEdge()); assert(m_from->flags() & QGraphicsItem::ItemIsMovable); assert(m_from->flags() & QGraphicsItem::ItemIsSelectable); assert(m_to->flags() & QGraphicsItem::ItemIsMovable); assert(m_to->flags() & QGraphicsItem::ItemIsSelectable); //qtedge itself is not movable //assert(qtedge->flags() & QGraphicsItem::ItemIsMovable); //assert(qtedge->flags() & QGraphicsItem::ItemIsSelectable); assert(qtedge->GetFrom()->flags() & QGraphicsItem::ItemIsMovable); assert(qtedge->GetFrom()->flags() & QGraphicsItem::ItemIsSelectable); assert(qtedge->GetTo()->flags() & QGraphicsItem::ItemIsMovable); assert(qtedge->GetTo()->flags() & QGraphicsItem::ItemIsSelectable); assert(qtedge->GetQtNode()->flags() & QGraphicsItem::ItemIsMovable); assert(qtedge->GetQtNode()->flags() & QGraphicsItem::ItemIsSelectable); this->m_qtedge_dialog->GetQtEdge()->GetFrom()->GetNode().GetConcept().SetName("From"); this->m_qtedge_dialog->GetQtEdge()->GetTo()->GetNode().GetConcept().SetName("To"); }
std::string GetMoveSAN(Position &position, const Move move) { const Square from = GetFrom(move); const Square to = GetTo(move); const Move moveType = GetMoveType(move); std::string result; if (moveType == MoveTypeCastle) { if (GetColumn(to) > FILE_E) { result = "O-O"; } else { result = "O-O-O"; } } else { // Piece that is moving const PieceType fromPieceType = GetPieceType(position.Board[from]); switch (fromPieceType) { case PAWN: break; case KNIGHT: result += "N"; break; case BISHOP: result += "B"; break; case ROOK: result += "R"; break; case QUEEN: result += "Q"; break; case KING: result += "K"; break; } Move legalMoves[256]; int legalMoveCount = GenerateLegalMoves(position, legalMoves); // Do we need to disambiguate? bool dupe = false, rowDiff = true, columnDiff = true; for (int i = 0; i < legalMoveCount; i++) { if (GetFrom(legalMoves[i]) != from && GetTo(legalMoves[i]) == to && GetPieceType(position.Board[GetFrom(legalMoves[i])]) == fromPieceType) { dupe = true; if (GetRow(GetFrom(legalMoves[i])) == GetRow(from)) { rowDiff = false; } if (GetColumn(GetFrom(legalMoves[i])) == GetColumn(from)) { columnDiff = false; } } } if (dupe) { if (columnDiff) { result += GetSquareSAN(from)[0]; } else if (rowDiff) { result += GetSquareSAN(from)[1]; } else { result += GetSquareSAN(from); } } else if (fromPieceType == PAWN && position.Board[to] != PIECE_NONE) { // Pawn captures need a row result += GetSquareSAN(from)[0]; } // Capture? if (position.Board[to] != PIECE_NONE || moveType == MoveTypeEnPassent) { result += "x"; } // Target square result += GetSquareSAN(to); } if (moveType == MoveTypePromotion) { switch (GetPromotionMoveType(move)) { case KNIGHT: result += "=N"; break; case BISHOP: result += "=B"; break; case ROOK: result += "=R"; break; case QUEEN: result += "=Q"; break; } } MoveUndo moveUndo; position.MakeMove(move, moveUndo); if (position.IsInCheck()) { Move checkEscapes[64]; result += GenerateCheckEscapeMoves(position, checkEscapes) == 0 ? "#" : "+"; } position.UnmakeMove(move, moveUndo); return result; }
TSeqPos CSeq_interval::GetStop (ESeqLocExtremes ext) const { return ext == eExtreme_Biological && x_IsMinusStrand()? GetFrom(): GetTo(); }
void wxSVGAnimateTransformElement::ApplyAnimation() { wxSVGElement* targetElement = GetTargetElement(); if (targetElement == NULL || GetDur() <= 0 || (GetTo().GetPropertyType() != wxSVG_ANIMATED_LENGTH && GetTo().GetPropertyType() != wxSVG_ANIMATED_LENGTH_LIST)) return; wxSVGLengthList values; if (GetCurrentTime() >= GetStartTime() + GetDur()) { if (GetTo().GetPropertyType() == wxSVG_ANIMATED_LENGTH) { values.push_back(GetTo().GetLength()); } else { values = GetTo().GetLengthList(); } } else if (GetCurrentTime() >= GetStartTime() && GetFrom().GetPropertyType() == GetTo().GetPropertyType() && GetFrom().GetLengthList().size() == GetTo().GetLengthList().size()) { if (GetTo().GetPropertyType() == wxSVG_ANIMATED_LENGTH) { values.Add(wxSVGLength(GetTo().GetLength().GetUnitType(), GetFrom().GetLength().GetValue() + (GetTo().GetLength().GetValue() - GetFrom().GetLength().GetValue())* (GetCurrentTime() - GetStartTime())/GetDur())); } else { for (unsigned int i = 0; i < GetFrom().GetLengthList().size(); i++) { const wxSVGLength& from = GetFrom().GetLengthList()[i]; const wxSVGLength& to = GetTo().GetLengthList()[i]; values.Add(wxSVGLength(to.GetUnitType(), from.GetValue() + (to.GetValue() - from.GetValue())*(GetCurrentTime() - GetStartTime())/GetDur())); } } } else { return; } wxSVGTransformable* transformable = wxSVGTransformable::GetSVGTransformable(*targetElement); if (transformable != NULL) { if (m_transformIdx == -1 || m_transformIdx >= (int) transformable->GetTransformList().GetAnimVal().size()) { wxSVGTransformList& transforms = transformable->GetTransformList().GetAnimVal(); if (GetAdditive() != wxSVG_ANIMATION_ADDITIVE_SUM) { transforms.Clear(); } wxSVGTransform* transform = new wxSVGTransform(); UpdateTransform(*transform, GetType(), values); transforms.Add(transform); m_transformIdx = transforms.size() - 1; } else { UpdateTransform(transformable->GetTransformList().GetAnimVal()[m_transformIdx], GetType(), values); } } else { wxSVGTransformList transforms; wxSVGTransform* transform = new wxSVGTransform(); UpdateTransform(*transform, GetType(), values); transforms.Add(transform); targetElement->SetAnimatedValue(GetAttributeName(), wxSVGAnimatedType(transforms)); } }
ribi::cmap::Node ribi::cmap::GetTo(const Edge& edge, const ConceptMap& c) noexcept { return GetTo(::find_first_custom_edge_with_my_edge(edge, c), c); }