def switch (value): def test (*args): return value in args return test class PositionCalculator pieces= [[11, 12, 13, 14, 15, 13, 12, 11], [16, 16, 16, 16, 16, 16, 16, 16], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [6, 6, 6, 6, 6, 6, 6, 6], [1, 2, 3, 4, 5, 3, 2, 1]] possible=[[0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0]] control=[[0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0]] def calculateControlofPosition (): y = 0 while not y >= 8: x = 0 while not x >= 8: with case as switch(location[y][x]): if case(1): calculateRook(0, y, x) if case(2): calculateKnight(0, y, x) if case(3): calculateBishop(0, y, x) if case(4): calculateQueen(0, y, x) if case(5): calculateKing(0, y, x) if case(6): calculatePawn(0, y, x) if case(11): calculateRook(1, y, x) if case(12): calculateKnight(1, y, x) if case(13): calculateBishop(1, y, x) if case(14): calculateQueen(1, y, x) if case(15): calculateKing(1, y, x) if case(16): calculatePawn(1, y, x) y += 1 y += 1 def calculateRook (player, y,x): pass def calculateBishop (player, y,x): pass def calculateKnight (player, y,x): pass def calculateQueen (player, y,x): pass def calculateKing (player, y,x): pass def calculatePawn (player, y,x): pass
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question