Check whether Bishop can take down Pawn or not | Function that return true if the Bishop can take down the pawn ; If pawn is at angle 45 or 225 degree from bishop 's Position ; If pawn is at angle 135 or 315 degree from bishop 's Position ; Bishop 's Position ; Pawn 's Position
< ? php function canTakeDown ( $ bishopX , $ bishopY , $ pawnX , $ pawnY ) { if ( $ pawnX - $ bishopX == $ pawnY - $ bishopY ) return true ; else if ( - $ pawnX + $ bishopX == $ pawnY - $ bishopY ) return true ; else return false ; } $ bishopX = 5 ; $ bishopY = 5 ; $ pawnX = 1 ; $ pawnY = 1 ; if ( canTakeDown ( $ bishopX , $ bishopY , $ pawnX , $ pawnY ) ) echo " Yes " ; else echo " No " ; ? >