0
私はチェスプログラムをやっていて、bpawn1-bpawn8のx位置とy位置をチェックしてxとyの位置が白いポーンと同じであるかどうかを調べることで、それはポーンを殺す。クラス内の変数の複数の値をチェックできますか?
class ChessPeice:
def __init__(self, color, x_position, y_positon):
self.color = color
self.x = self.x_position
self.y = self.y_position
@staticmethod
def move(x_position, y_position):
pass
class WPawn(ChessPeice):
def move(x_position, y_position):
if self.x_position + 1 == x_position and self.y_position == y_position:
self.x_position += 1
elif self.x_position + 1 == x_position and self.y_position + 1 == y_position:
if self.x_positon + 1 == bpawn1.x_position and self.y_positon + 1 == bpawn1.y_position
bpawn1 == "dead"