|
| 1 | +''' |
| 2 | +This function's main goal is to translate the coordinates of the mouse into what position of the chessboard the mouse is in |
| 3 | +This was a repetative implementation, there might (most likely) another way to implement this that is more effecient both in the run time, |
| 4 | +and the time it took to code |
| 5 | +
|
| 6 | +IF YOU DON'T KNOW THE CHESS POSITIONS: http://www.chess-poster.com/english/learn_chess/notation/images/coordinates_2.gif |
| 7 | +''' |
| 8 | + |
| 9 | +class find_position(): |
| 10 | + def chess_position(self, pos): |
| 11 | + if pos[0] <= 102.5 and pos[1] <= 100: |
| 12 | + return "a1" |
| 13 | + elif pos[0] <= 205 and pos[1] <= 100: |
| 14 | + return "b1" |
| 15 | + elif pos[0] <= 307.5 and pos[1] <= 100: |
| 16 | + return "c1" |
| 17 | + elif pos[0] <= 410 and pos[1] <= 100: |
| 18 | + return "d1" |
| 19 | + elif pos[0] <= 512.5 and pos[1] <= 100: |
| 20 | + return "e1" |
| 21 | + elif pos[0] <= 615 and pos[1] <= 100: |
| 22 | + return "f1" |
| 23 | + elif pos[0] <= 717.5 and pos[1] <= 100: |
| 24 | + return "g1" |
| 25 | + elif pos[0] <= 820 and pos[1] <= 100: |
| 26 | + return "h1" |
| 27 | + elif pos[0] <= 102.5 and pos[1] <= 200: |
| 28 | + return("a2") |
| 29 | + elif pos[0] <= 205 and pos[1] <= 200: |
| 30 | + return("b2") |
| 31 | + elif pos[0] <= 307.5 and pos[1] <= 200: |
| 32 | + return("c2") |
| 33 | + elif pos[0] <= 410 and pos[1] <= 200: |
| 34 | + return("d2") |
| 35 | + elif pos[0] <= 512.5 and pos[1] <= 200: |
| 36 | + return("e2") |
| 37 | + elif pos[0] <= 615 and pos[1] <= 200: |
| 38 | + return("f2") |
| 39 | + elif pos[0] <= 717.5 and pos[1] <= 200: |
| 40 | + return("g2") |
| 41 | + elif pos[0] <= 820 and pos[1] <= 200: |
| 42 | + return("h2") |
| 43 | + elif pos[0] <= 102.5 and pos[1] <= 300: |
| 44 | + return("a3") |
| 45 | + elif pos[0] <= 205 and pos[1] <= 300: |
| 46 | + return("b3") |
| 47 | + elif pos[0] <= 307.5 and pos[1] <= 300: |
| 48 | + return("c3") |
| 49 | + elif pos[0] <= 410 and pos[1] <= 300: |
| 50 | + return("d3") |
| 51 | + elif pos[0] <= 512.5 and pos[1] <= 300: |
| 52 | + return("e3") |
| 53 | + elif pos[0] <= 615 and pos[1] <= 300: |
| 54 | + return("f3") |
| 55 | + elif pos[0] <= 717.5 and pos[1] <= 300: |
| 56 | + return("g3") |
| 57 | + elif pos[0] <= 820 and pos[1] <= 300: |
| 58 | + return("h3") |
| 59 | + elif pos[0] <= 102.5 and pos[1] <= 400: |
| 60 | + return("a4") |
| 61 | + elif pos[0] <= 205 and pos[1] <= 400: |
| 62 | + return("b4") |
| 63 | + elif pos[0] <= 307.5 and pos[1] <= 400: |
| 64 | + return("c4") |
| 65 | + elif pos[0] <= 410 and pos[1] <= 400: |
| 66 | + return("d4") |
| 67 | + elif pos[0] <= 512.5 and pos[1] <= 400: |
| 68 | + return("e4") |
| 69 | + elif pos[0] <= 615 and pos[1] <= 400: |
| 70 | + return("f4") |
| 71 | + elif pos[0] <= 717.5 and pos[1] <= 400: |
| 72 | + return("g4") |
| 73 | + elif pos[0] <= 820 and pos[1] <= 400: |
| 74 | + return("h4") |
| 75 | + elif pos[0] <= 102.5 and pos[1] <= 500: |
| 76 | + return("a5") |
| 77 | + elif pos[0] <= 205 and pos[1] <= 500: |
| 78 | + return("b5") |
| 79 | + elif pos[0] <= 307.5 and pos[1] <= 500: |
| 80 | + return("c5") |
| 81 | + elif pos[0] <= 410 and pos[1] <= 500: |
| 82 | + return("d5") |
| 83 | + elif pos[0] <= 512.5 and pos[1] <= 500: |
| 84 | + return("e5") |
| 85 | + elif pos[0] <= 615 and pos[1] <= 500: |
| 86 | + return("f5") |
| 87 | + elif pos[0] <= 717.5 and pos[1] <= 500: |
| 88 | + return("g5") |
| 89 | + elif pos[0] <= 820 and pos[1] <= 500: |
| 90 | + return("h5") |
| 91 | + elif pos[0] <= 102.5 and pos[1] <= 600: |
| 92 | + return("a6") |
| 93 | + elif pos[0] <= 205 and pos[1] <= 600: |
| 94 | + return("b6") |
| 95 | + elif pos[0] <= 307.5 and pos[1] <= 600: |
| 96 | + return("c6") |
| 97 | + elif pos[0] <= 410 and pos[1] <= 600: |
| 98 | + return("d6") |
| 99 | + elif pos[0] <= 512.5 and pos[1] <= 600: |
| 100 | + return("e6") |
| 101 | + elif pos[0] <= 615 and pos[1] <= 600: |
| 102 | + return("f6") |
| 103 | + elif pos[0] <= 717.5 and pos[1] <= 600: |
| 104 | + return("g6") |
| 105 | + elif pos[0] <= 820 and pos[1] <= 600: |
| 106 | + return("h6") |
| 107 | + elif pos[0] <= 102.5 and pos[1] <= 700: |
| 108 | + return("a7") |
| 109 | + elif pos[0] <= 205 and pos[1] <= 700: |
| 110 | + return("b7") |
| 111 | + elif pos[0] <= 307.5 and pos[1] <= 700: |
| 112 | + return("c7") |
| 113 | + elif pos[0] <= 410 and pos[1] <= 700: |
| 114 | + return("d7") |
| 115 | + elif pos[0] <= 512.5 and pos[1] <= 700: |
| 116 | + return("e7") |
| 117 | + elif pos[0] <= 615 and pos[1] <= 700: |
| 118 | + return("f7") |
| 119 | + elif pos[0] <= 717.5 and pos[1] <= 700: |
| 120 | + return("g7") |
| 121 | + elif pos[0] <= 820 and pos[1] <= 700: |
| 122 | + return("h7") |
| 123 | + elif pos[0] <= 102.5 and pos[1] <= 800: |
| 124 | + return("a8") |
| 125 | + elif pos[0] <= 205 and pos[1] <= 800: |
| 126 | + return("b8") |
| 127 | + elif pos[0] <= 307.5 and pos[1] <= 800: |
| 128 | + return("c8") |
| 129 | + elif pos[0] <= 410 and pos[1] <= 800: |
| 130 | + return("d8") |
| 131 | + elif pos[0] <= 512.5 and pos[1] <= 800: |
| 132 | + return("e8") |
| 133 | + elif pos[0] <= 615 and pos[1] <= 800: |
| 134 | + return("f8") |
| 135 | + elif pos[0] <= 717.5 and pos[1] <= 800: |
| 136 | + return("g8") |
| 137 | + elif pos[0] <= 820 and pos[1] <= 800: |
| 138 | + return("h8") |
0 commit comments