私がしたいことは、座標系(grid [0] [0])を 'A1'、(grid [0] [1]) 'A2'グリッド[1] [0])を 'B1'、(グリッド[1] [1])を 'B2'と呼びます。私は、ゲームが始まる前に、プレイヤーがそのコンテンツを削除するために座標を選択しなければならないゲームを作成しています。今のようPythonで多次元配列座標にラベルを付ける
B W B W A1 A2 A3 A4 W B W B I want to access like this B1 B2 B3 B4 B W B W C1 C2 C3 C4
、私は彼らが(自分の作品のいずれかとすることができる)を削除したいというユーザー作品(「B」または「W」)を求めています。私は左上の 'B'に 'A1'と入力することができるようにしたいと思います。
removeB = input("BLACK, remove one of your pieces by typing in it's coordinates")
私は、指定された座標にB2 '変数のA1、A2、B1の割り当てについては移動するかどうかはわかりません。それが助け場合、私は以下の私のコードを添付した
if(removeB == A1): grid[row -1][col -1].append('-') # '-' = empty
:
import random numrows = 3 numcols = 4 def initial(): grid = [] count = 0 y = 2 for x in range(numrows)s grid.append([]) for y in range(numcols): if ((x + y)%2): grid[x].append('W') else: grid[x].append('B') for x in grid: print(*x, sep=' ',end="\n") print("") color = input("Press 'Enter' to see which color you will be playing") print("") rand=random.randrange(1,3) if(rand == 1): print("Player1 you will be playing as BLACK") print("Player2 you will be playing as WHITE") else: print("Player1 you will be playing as WHITE") print("Player2 you will be playing as BLACK") print("") print(" The game board can be navigated as if it were: ") print("") example = '''\ A1 A2 A3 A4 B W B W B1 B2 B3 B4 = W B W B C1 C2 C3 C4 B W B W ''' print(example) print("and so on.....") print("") if(rand == 1): removeB = input("~BLACK Player, remove one of your pieces by typing in the coordinates: ") removeW = input("~WHITE Player, remove one of your pieces by typing in the coordinates: ") else: removeW = input("~WHITE Player, remove one of your pieces by typing in the coordinates: ") removeB = input("~BLACK Player, remove one of your pieces by typing in the coordinates: ")
は、事前にいただきありがとうございます私のような何かをできるようにしたいと思います私の質問に答える時間と労力。
P.S.私のコードは非常にノービーであることを知っています。私はPython LOLに3週間しかいません。私はコードで終わっていない、この部分にちょうどハングアップ....