Core plug-in algorithms for QQ connection (point-to-point detection)

Source: Internet
Author: User
Bool checkline (point P1, point P2) {int X, Y, T; // If the X axis is the same, if the Y axis is the same, one point is null, and another point is null if (p1.x = p2.x) & (p1.y = p2.y) & (chessdata [p1.y] [p1.x] = 0) & (chessdata [p2.y] [p2.x] = 0 )) {return turn;} // If the P1 axis is smaller than 0 and greater than 18 or the P2 axis is smaller than 0 and greater than 18 else if (p1.x <0) | (p1.x> 18) | (p1.y <0) | (p1.y> 10) | (p2.x <0) | (p2.x> 18) | (p2.y <0) | (p2.y> 10) {return false;} If (p1.x = p2.x) // if one point is the same as the other X axis {If (p1.y> p2.y) // If the score is low, (if the result of the judgment is below The above is the same, and we will judge from the above pawn) {T = p1.y; p1.y = p2.y; p2.y = T ;} // exchange the y values of P1 and P2 // if the above is not true, execute the following for (y = p1.y; y <= p2.y; y ++) // If the X axis is the same, it traverses the Y axis, that is, whether there is a pawn channel under P1 {If (chessdata [y] [p1.x]! = 0) {return false;} // if there is something under P1, you cannot directly connect} If (p1.y = p2.y) // If P1 and p2y axes are the same {If (p1.x> p2.x) // if one is the same as the other (if the other is the same as the other one, then, judge from the Front) {T = p1.x; p1.x = p2.x; p2.x = T;} For (x = p1.x; x <p2.x; X ++) // traverse the X axis backward, that is, to determine whether there is a pawn line behind P1 {If (chessdata [p1.y] [x]! = 0) {return false;} // if there is something behind P1, you cannot directly connect} return true; // if you can perform this step, it can be directly connected (one line )}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.