There are three main cases for determining whether a connection can be made through review.
1. There is no inflection point during the connection, which is further divided into horizontal and vertical
2. There is an inflection point during connection.
3. There are two inflection points during the connection, which is also the most difficult part of the game.
First, let's see if there is no inflection point.
// Determine the public Boolean ishorizontal () in the horizontal direction {// used to record the large number, the small number int bignumx = 0; int smallnumx = 0; // first determine the level line if (lastclick [1] = curclick [1]) {If (lastclick [0]> curclick [0]) {bignumx = lastclick [0]; smallnumx = curclick [0];} else if (lastclick [0] <curclick [0]) {bignumx = curclick [0]; smallnumx = lastclick [0];} // If (smallnumx + 1 = bignumx) {return true ;} else // not adjacent {for (INT I = smallnumx + 1; I <= bignumx; I ++) {If (pieces [I] [lastclick [1] = 1) // if there is a square block between the two sides, return false; else return true ;}} return false ;} // determine public Boolean isvertical () {int bignumy = 0; int smallnumy = 0; If (lastclick [1]> curclick [1]) in the vertical direction {bignumy = lastclick [1]; smallnumy = curclick [1];} else if (lastclick [1] <curclick [1]) {bignumy = curclick [1]; smallnumy = lastclick [1];} // If (smallnumy + 1 = bignumy) {return true;} else {for (INT I = smallnumy + 1; I <bignumy; I ++) {If (pieces [lastclick [0] [I] = 1) // if there is a square block between the two sides, return false; else return true;} return false ;}