Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Board = {
- a1 = {x=1, y=1,Piece= "Rw"},
- a2 = {x=2, y=1,Piece= "Hw"},
- a3 = {x=3, y=1,Piece= "Bw"},
- a4 = {x=4, y=1,Piece= "Qw"},
- a5 = {x=5, y=1,Piece= "Kw"},
- a6 = {x=6, y=1,Piece= "Bw"},
- a7 = {x=7, y=1,Piece= "Hw"},
- a8 = {x=8, y=1,Piece= "Rw"},
- b1 = {x=1, y=2,Piece= "Pw"},
- b2 = {x=2, y=2,Piece= "Pw"},
- b3 = {x=3, y=2,Piece= "Pw"},
- b4 = {x=4, y=2,Piece= "Pw"},
- b5 = {x=5, y=2,Piece= "Pw"},
- b6 = {x=6, y=2,Piece= "Pw"},
- b7 = {x=7, y=2,Piece= "Pw"},
- b8 = {x=8, y=2,Piece= "Pw"},
- c1 = {x=1, y=3,Piece= "Na"},
- c2 = {x=2, y=3,Piece= "Na"},
- c3 = {x=3, y=3,Piece= "Na"},
- c4 = {x=4, y=3,Piece= "Na"},
- c5 = {x=5, y=3,Piece= "Na"},
- c6 = {x=6, y=3,Piece= "Na"},
- c7 = {x=7, y=3,Piece= "Na"},
- c8 = {x=8, y=3,Piece= "Na"},
- d1 = {x=1, y=4,Piece= "Na"},
- d2 = {x=2, y=4,Piece= "Na"},
- d3 = {x=3, y=4,Piece= "Na"},
- d4 = {x=4, y=4,Piece= "Na"},
- d5 = {x=5, y=4,Piece= "Na"},
- d6 = {x=6, y=4,Piece= "Na"},
- d7 = {x=7, y=4,Piece= "Na"},
- d8 = {x=8, y=4,Piece= "Na"},
- e1 = {x=1, y=5,Piece= "Na"},
- e2 = {x=2, y=5,Piece= "Na"},
- e3 = {x=3, y=5,Piece= "Na"},
- e4 = {x=4, y=5,Piece= "Na"},
- e5 = {x=5, y=5,Piece= "Na"},
- e6 = {x=6, y=5,Piece= "Na"},
- e7 = {x=7, y=5,Piece= "Na"},
- e8 = {x=8, y=5,Piece= "Na"},
- f1 = {x=1, y=6,Piece= "Na"},
- f2 = {x=2, y=6,Piece= "Na"},
- f3 = {x=3, y=6,Piece= "Na"},
- f4 = {x=4, y=6,Piece= "Na"},
- f5 = {x=5, y=6,Piece= "Na"},
- f6 = {x=6, y=6,Piece= "Na"},
- f7 = {x=7, y=6,Piece= "Na"},
- f8 = {x=8, y=6,Piece= "Na"},
- g1 = {x=1, y=7,Piece= "Pb"},
- g2 = {x=2, y=7,Piece= "Pb"},
- g3 = {x=3, y=7,Piece= "Pb"},
- g4 = {x=4, y=7,Piece= "Pb"},
- g5 = {x=5, y=7,Piece= "Pb"},
- g6 = {x=6, y=7,Piece= "Pb"},
- g7 = {x=7, y=7,Piece= "Pb"},
- g8 = {x=8, y=7,Piece= "Pb"},
- h1 = {x=1, y=8,Piece= "Rb"},
- h2 = {x=2, y=8,Piece= "Hb"},
- h3 = {x=3, y=8,Piece= "Bb"},
- h4 = {x=4, y=8,Piece= "Kb"},
- h5 = {x=5, y=8,Piece= "Qb"},
- h6 = {x=6, y=8,Piece= "Bb"},
- h7 = {x=7, y=8,Piece= "Hb"},
- h8 = {x=8, y=8,Piece= "Rb"},
- }
- White = {"Pw","Rw","Bw","Hw","Qw","Kw"}
- Black = {"Pb","Rb","Bb","Hb","Qb","Kb"}
- function coordstoclass(x, y)
- if x < 1 or x > 8 or y < 1 or y > 8 then
- return {x = nil,y = nil,Piece = "void"}
- end
- if x == 1 then
- if y == 1 then
- return Board.a1
- elseif y == 2 then
- return Board.a2
- elseif y == 3 then
- return Board.a3
- elseif y == 4 then
- return Board.a4
- elseif y == 5 then
- return Board.a5
- elseif y == 6 then
- return Board.a6
- elseif y == 7 then
- return Board.a7
- elseif y == 8 then
- return Board.a8
- end
- elseif x == 2 then
- if y == 1 then
- return Board.b1
- elseif y == 2 then
- return Board.b2
- elseif y == 3 then
- return Board.b3
- elseif y == 4 then
- return Board.b4
- elseif y == 5 then
- return Board.b5
- elseif y == 6 then
- return Board.b6
- elseif y == 7 then
- return Board.b7
- elseif y == 8 then
- return Board.b8
- end
- elseif x == 3 then
- if y == 1 then
- return Board.c1
- elseif y == 2 then
- return Board.c2
- elseif y == 3 then
- return Board.c3
- elseif y == 4 then
- return Board.c4
- elseif y == 5 then
- return Board.c5
- elseif y == 6 then
- return Board.c6
- elseif y == 7 then
- return Board.c7
- elseif y == 8 then
- return Board.c8
- end
- elseif x == 4 then
- if y == 1 then
- return Board.d1
- elseif y == 2 then
- return Board.d2
- elseif y == 3 then
- return Board.d3
- elseif y == 4 then
- return Board.d4
- elseif y == 5 then
- return Board.d5
- elseif y == 6 then
- return Board.d6
- elseif y == 7 then
- return Board.d7
- elseif y == 8 then
- return Board.d8
- end
- elseif x == 5 then
- if y == 1 then
- return Board.e1
- elseif y == 2 then
- return Board.e2
- elseif y == 3 then
- return Board.e3
- elseif y == 4 then
- return Board.e4
- elseif y == 5 then
- return Board.e5
- elseif y == 6 then
- return Board.e6
- elseif y == 7 then
- return Board.e7
- elseif y == 8 then
- return Board.e8
- end
- elseif x == 6 then
- if y == 1 then
- return Board.f1
- elseif y == 2 then
- return Board.f2
- elseif y == 3 then
- return Board.f3
- elseif y == 4 then
- return Board.f4
- elseif y == 5 then
- return Board.f5
- elseif y == 6 then
- return Board.f6
- elseif y == 7 then
- return Board.f7
- elseif y == 8 then
- return Board.f8
- end
- elseif x == 7 then
- if y == 1 then
- return Board.g1
- elseif y == 2 then
- return Board.g2
- elseif y == 3 then
- return Board.g3
- elseif y == 4 then
- return Board.g4
- elseif y == 5 then
- return Board.g5
- elseif y == 6 then
- return Board.g6
- elseif y == 7 then
- return Board.g7
- elseif y == 8 then
- return Board.g8
- end
- elseif x == 8 then
- if y == 1 then
- return Board.h1
- elseif y == 2 then
- return Board.h2
- elseif y == 3 then
- return Board.h3
- elseif y == 4 then
- return Board.h4
- elseif y == 5 then
- return Board.h5
- elseif y == 6 then
- return Board.h6
- elseif y == 7 then
- return Board.h7
- elseif y == 8 then
- return Board.h8
- end
- end
- end
- function getmoves(x,y)
- if Board.Piece == "Pw"
- and (coordstoclass(x,y+1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-1,y+1).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x+1,y+1).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x-1,y+1).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x+1,y+1).Piece) == White then
- return Illegal
- end
- if y == 2
- and (coordstoclass(x,y+1).Piece) == Na
- and (coordstoclass(x,y+2).Piece) == Na then
- return Legal
- end
- if Board.Piece == "Pb"
- and (coordstoclass(x,y-1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-1,y-1).Piece) == White then
- return Legal
- end
- if (coordstoclass(x+1,y-1).Piece) == White then
- return Legal
- end
- if (coordstoclass(x-1,y+1).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x+1,y+1).Piece) == Black then
- return Illegal
- end
- if y == 2
- and (coordstoclass(x,y-1).Piece) == Na
- and (coordstoclass(x,y-2).Piece) == Na then
- return Legal
- end
- if Board.Piece == "Hw"
- and (coordstoclass(x+1,y+3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-1,y+3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-1,y-3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+1,y-3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+3,y+1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+3,y-1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-3,y+1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-3,y-1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+1,y+3).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x-1,y+3).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x-1,y-3).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x+1,y-3).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x+3,y+1).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x+3,y-1).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x-3,y+1).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x-3,y-1).Piece) == Black then
- return Legal
- end
- if (coordstoclass(x+1,y+3).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x-1,y+3).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x-1,y-3).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x+1,y-3).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x+3,y+1).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x+3,y-1).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x-3,y+1).Piece) == White then
- return Illegal
- end
- if (coordstoclass(x-3,y-1).Piece) == White then
- return Illegal
- end
- if Board.Piece == "Hb"
- and (coordstoclass(x+1,y+3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-1,y+3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-1,y-3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+1,y-3).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+3,y+1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+3,y-1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-3,y+1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x-3,y-1).Piece) == Na then
- return Legal
- end
- if (coordstoclass(x+1,y+3).Piece) == White then
- return Legal
- end
- if (coordstoclass(x-1,y+3).Piece) == White then
- return Legal
- end
- if (coordstoclass(x-1,y-3).Piece) == White then
- return Legal
- end
- if (coordstoclass(x+1,y-3).Piece) == White then
- return Legal
- end
- if (coordstoclass(x+3,y+1).Piece) == White then
- return Legal
- end
- if (coordstoclass(x+3,y-1).Piece) == White then
- return Legal
- end
- if (coordstoclass(x-3,y+1).Piece) == White then
- return Legal
- end
- if (coordstoclass(x-3,y-1).Piece) == White then
- return Legal
- end
- if (coordstoclass(x+1,y+3).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x-1,y+3).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x-1,y-3).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x+1,y-3).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x+3,y+1).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x+3,y-1).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x-3,y+1).Piece) == Black then
- return Illegal
- end
- if (coordstoclass(x-3,y-1).Piece) == Black then
- return Illegal
- end
- end
- print(getmoves(7,8))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement