Advertisement
Guest User

Checkers006bkup before highlight board

a guest
Jan 24th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 36.22 KB | None | 0 0
  1. # TO-DO:
  2. # check for win, check for tie
  3. # kings
  4. # commands - reselect, undo move, reset board
  5. # random computer
  6. # force eat option
  7.  
  8. black = "\033[30m"
  9. green = "\033[32m"
  10. yellow = "\033[33m"
  11. red = "\033[31m"
  12. blue = "\033[34m"
  13. reset = "\033[0m"
  14.  
  15. p1 = f"{red}◉ {reset}"
  16. p2 = f"{blue}◉ {reset}"
  17.  
  18. # Default board reference
  19. d_board = ["0", "1", "2", "3", "4", "5", "6", "7",
  20.            "8", "9", "10", "11", "12", "13", "14", "15",
  21.            "16", "17", "18", "19", "20", "21", "22", "23",
  22.            "24", "25", "26", "27", "28", "29", "30", "31",
  23.            "32", "33", "34", "35", "36", "37", "38", "39",
  24.            "40", "41", "42", "43", "44", "45", "46", "47",
  25.            "48", "49", "50", "51", "52", "53", "54", "55",
  26.            "56", "57", "58", "59", "60", "61", "62", "63"]
  27.  
  28. available_spots = ["1", "3", "5", "7",
  29.                    "8", "10", "12", "14",
  30.                    "17", "19", "21", "23",
  31.                    "24", "26", "28", "30",
  32.                    "33", "35", "37", "39",
  33.                    "40", "42", "44", "46",
  34.                    "49", "51", "53", "55",
  35.                    "56", "58", "60", "62"]
  36.  
  37. # Realtime board and reset
  38. board = ["0", p2, "2", p2, "4", p2, "6", p2,
  39.          p2, "9", p2, "11", p2, "13", p2, "15",
  40.          "16", p2, "18", p2, "20", p2, "22", p2,
  41.          "24", "25", "26", "27", "28", "29", "30", "31",
  42.          "32", "33", "34", "35", "36", "37", "38", "39",
  43.          p1, "41", p1, "43", p1, "45", p1, "47",
  44.          "48", p1, "50", p1, "52", p1, "54", p1,
  45.          p1, "57", p1, "59", p1, "61", p1, "63"]
  46.  
  47. # TESTING BOARD
  48. boardr = ["0", "1", "2", "3", "4", "5", "6", "7",
  49.            "8", "9", "10", "11", "12", "13", "14", "15",
  50.            "16", "17", "18", p2, "20", p2, "22", "23",
  51.            "24", "25", "26", "27", "28", "29", "30", "31",
  52.            "32", p2, "34", p2, "36", p2, "38", "39",
  53.            "40", "41", "42", "43", "44", "45", "46", "47",
  54.            "48", p2, "50", p2, "52", "53", "54", "55",
  55.            "56", "57", p1, "59", "60", "61", "62", "63"]
  56.  
  57.  
  58. def display_board():
  59.     b1 = []
  60.     for index, each in enumerate(board):
  61.         if each.isdigit():
  62.             if int(each) < 10:
  63.                 b1.append(f"0{each}")
  64.             else:
  65.                 b1.append(each)
  66.         else:
  67.             b1.append(each)
  68.     b2 = []
  69.     for index, each in enumerate(board):
  70.         if each.isdigit():
  71.             if int(each) < 10:
  72.                 b2.append(f"0{each}")
  73.             else:
  74.                 b2.append(each)
  75.         if each == p1:
  76.             if index < 10:
  77.                 b2.append(f"{red}0{index}{reset}")
  78.             else:
  79.                 b2.append(f"{red}{index}{reset}")
  80.         elif each == p2:
  81.             if index < 10:
  82.                 b2.append(f"{blue}0{index}{reset}")
  83.             else:
  84.                 b2.append(f"{blue}{index}{reset}")
  85.     b3 = []
  86.     for index, each in enumerate(board):
  87.         if selection_process is True:
  88.             if index in possible_pieces:
  89.                 if index < 10:
  90.                     b3.append(f"{green}0{index}{reset}")
  91.                 else:
  92.                     b3.append(f"{green}{index}{reset}")
  93.             else:
  94.                 if each.isdigit():
  95.                     if int(each) < 10:
  96.                         b3.append(f"0{each}")
  97.                     else:
  98.                         b3.append(each)
  99.                 if each == p1:
  100.                     if index < 10:
  101.                         b3.append(f"{red}0{index}{reset}")
  102.                     else:
  103.                         b3.append(f"{red}{index}{reset}")
  104.                 elif each == p2:
  105.                     if index < 10:
  106.                         b3.append(f"{blue}0{index}{reset}")
  107.                     else:
  108.                         b3.append(f"{blue}{index}{reset}")
  109.         elif cord_process is True:
  110.             if index == int(selection):
  111.                 if index < 10:
  112.                     b3.append(f"{yellow}0{index}{reset}")
  113.                 else:
  114.                     b3.append(f"{yellow}{index}{reset}")
  115.             elif index in fpvision:
  116.                 if index < 10:
  117.                     b3.append(f"{green}0{index}{reset}")
  118.                 else:
  119.                     b3.append(f"{green}{index}{reset}")
  120.             else:
  121.                 if each.isdigit():
  122.                     if int(each) < 10:
  123.                         b3.append(f"0{each}")
  124.                     else:
  125.                         b3.append(each)
  126.                 if each == p1:
  127.                     if index < 10:
  128.                         b3.append(f"{red}0{index}{reset}")
  129.                     else:
  130.                         b3.append(f"{red}{index}{reset}")
  131.                 elif each == p2:
  132.                     if index < 10:
  133.                         b3.append(f"{blue}0{index}{reset}")
  134.                     else:
  135.                         b3.append(f"{blue}{index}{reset}")
  136.         else:
  137.             if each.isdigit():
  138.                 if int(each) < 10:
  139.                     b3.append(f"0{each}")
  140.                 else:
  141.                     b3.append(each)
  142.             if each == p1:
  143.                 if index < 10:
  144.                     b3.append(f"{red}0{index}{reset}")
  145.                 else:
  146.                     b3.append(f"{red}{index}{reset}")
  147.             elif each == p2:
  148.                 if index < 10:
  149.                     b3.append(f"{blue}0{index}{reset}")
  150.                 else:
  151.                     b3.append(f"{blue}{index}{reset}")
  152.     print(f"""
  153.      Realtime board                     Debug
  154. ■■■■■■■■■■■■■■■■■■■■■■■■■■■   ■■■■■■■■■■■■■■■■■■■■■■■■■■■
  155. █ {b1[0]} {b1[1]} {b1[2]} {b1[3]} {b1[4]} {b1[5]} {b1[6]} {b1[7]} █   █ {b3[0]} {b3[1]} {b3[2]} {b3[3]} {b3[4]} {b3[5]} {b3[6]} {b3[7]} █
  156. █ {b1[8]} {b1[9]} {b1[10]} {b1[11]} {b1[12]} {b1[13]} {b1[14]} {b1[15]} █   █ {b3[8]} {b3[9]} {b3[10]} {b3[11]} {b3[12]} {b3[13]} {b3[14]} {b3[15]} █
  157. █ {b1[16]} {b1[17]} {b1[18]} {b1[19]} {b1[20]} {b1[21]} {b1[22]} {b1[23]} █   █ {b3[16]} {b3[17]} {b3[18]} {b3[19]} {b3[20]} {b3[21]} {b3[22]} {b3[23]} █
  158. █ {b1[24]} {b1[25]} {b1[26]} {b1[27]} {b1[28]} {b1[29]} {b1[30]} {b1[31]} █   █ {b3[24]} {b3[25]} {b3[26]} {b3[27]} {b3[28]} {b3[29]} {b3[30]} {b3[31]} █
  159. █ {b1[32]} {b1[33]} {b1[34]} {b1[35]} {b1[36]} {b1[37]} {b1[38]} {b1[39]} █   █ {b3[32]} {b3[33]} {b3[34]} {b3[35]} {b3[36]} {b3[37]} {b3[38]} {b3[39]} █
  160. █ {b1[40]} {b1[41]} {b1[42]} {b1[43]} {b1[44]} {b1[45]} {b1[46]} {b1[47]} █   █ {b3[40]} {b3[41]} {b3[42]} {b3[43]} {b3[44]} {b3[45]} {b3[46]} {b3[47]} █
  161. █ {b1[48]} {b1[49]} {b1[50]} {b1[51]} {b1[52]} {b1[53]} {b1[54]} {b1[55]} █   █ {b3[48]} {b3[49]} {b3[50]} {b3[51]} {b3[52]} {b3[53]} {b3[54]} {b3[55]} █
  162. █ {b1[56]} {b1[57]} {b1[58]} {b1[59]} {b1[60]} {b1[61]} {b1[62]} {b1[63]} █   █ {b3[56]} {b3[57]} {b3[58]} {b3[59]} {b3[60]} {b3[61]} {b3[62]} {b3[63]} █
  163. ■■■■■■■■■■■■■■■■■■■■■■■■■■■   ■■■■■■■■■■■■■■■■■■■■■■■■■■■""")
  164.  
  165.  
  166. def check_for_win():
  167.     return
  168.  
  169.  
  170. def switch_player():
  171.     global current_player
  172.     if current_player == p1:
  173.         current_player = p2
  174.     else:
  175.         current_player = p1
  176.  
  177.  
  178. def input_turn():
  179.     return
  180.  
  181.  
  182. def can_move(pawn):
  183.     pawn = int(pawn)
  184.     if d_board[pawn] not in available_spots:
  185.         return False
  186.  
  187.     if current_player == p1:
  188.         if pawn - 7 > 0:
  189.             if board[pawn - 7] in available_spots or board[pawn - 9] in available_spots:
  190.                 return True
  191.  
  192.             if d_board[pawn - 7] not in available_spots or board[pawn - 7] == p1:
  193.                 if board[pawn - 9] == p2:
  194.                     if board[pawn - 18] in available_spots:
  195.                         return True
  196.                     else:
  197.                         return False
  198.                 else:
  199.                     return False
  200.  
  201.             elif board[pawn - 7] == p2:
  202.                 if board[pawn - 14] in available_spots:
  203.                     return True
  204.                 elif board[pawn - 9] == p2:
  205.                     if board[pawn - 18] in available_spots:
  206.                         return True
  207.                     else:
  208.                         return False
  209.                 else:
  210.                     return False
  211.         return False
  212.  
  213.     if current_player == p2:
  214.         if pawn + 7 < 63:
  215.             if board[pawn + 7] in available_spots or board[pawn + 9] in available_spots:
  216.                 return True
  217.  
  218.             if d_board[pawn + 7] not in available_spots or board[pawn + 7] == p2:
  219.                 if board[pawn + 9] == p1:
  220.                     if board[pawn + 18] in available_spots:
  221.                         return True
  222.                     else:
  223.                         return False
  224.                 else:
  225.                     return False
  226.  
  227.             elif board[pawn + 7] == p1:
  228.                 if board[pawn + 14] in available_spots:
  229.                     return True
  230.                 elif board[pawn + 9] == p1:
  231.                     if board[pawn + 18] in available_spots:
  232.                         return True
  233.                     else:
  234.                         return False
  235.                 else:
  236.                     return False
  237.         return False
  238.  
  239.  
  240. def can_eat(pos):
  241.     if pos not in available_spots:
  242.         return False
  243.     pos = int(pos)
  244.  
  245.     if current_player == p1:
  246.         if d_board[pos - 7] in available_spots and board[pos - 7] == p2:
  247.             if board[pos - 14] in available_spots:
  248.                 return True
  249.         if d_board[pos - 9] in available_spots and board[pos - 9] == p2:
  250.             if board[pos - 18] in available_spots:
  251.                 return True
  252.         return False
  253.  
  254.     if current_player == p2:
  255.         if d_board[pos + 7] in available_spots and board[pos + 7] == p1:
  256.             if board[pos + 14] in available_spots:
  257.                 return True
  258.         if d_board[pos + 9] in available_spots and board[pos + 9] == p1:
  259.             if board[pos + 18] in available_spots:
  260.                 return True
  261.         return False
  262.  
  263.  
  264. selection = None
  265. selection_process = False
  266. cord_process = False
  267. pvision = []
  268. epvision = []
  269. fpvision = []
  270. possible_pieces = []
  271.  
  272.  
  273. def select_pawn():
  274.     global board, selection_process, possible_pieces, selection, cord_process, pvision, epvision, fpvision
  275.  
  276.     # possible_pieces = []
  277.     # for index, each in enumerate(board):
  278.     #  if each == current_player and can_move(index):
  279.     #       possible_pieces.append(index)
  280.     # print(f"possible_pieces = {possible_pieces}")
  281.     # simplified:
  282.     possible_pieces = [index for index, each in enumerate(board) if each == current_player and can_move(index)]
  283.  
  284.     selection_process = True
  285.     display_board()
  286.     selection = input(f"{current_player}'s turn. Select a pawn: ")
  287.     while True:
  288.         if not selection.isdigit():
  289.             selection = input(f"Invalid input. Possible options: {green}{possible_pieces}{reset} Try again: ")
  290.             continue
  291.         if int(selection) not in possible_pieces:
  292.             selection = input(f"Invalid input. Possible options: {green}{possible_pieces}{reset} Try again: ")
  293.             continue
  294.         else:
  295.             break
  296.     selection.lstrip('0')
  297.  
  298.     selection_process = False
  299.  
  300.     # PVISION: peripheral vision possible moves including illegal jumps
  301.     if current_player == p1:
  302.         calclist = [f"{int(selection) - 7}", f"{int(selection) - 14}", f"{int(selection) - 28}",
  303.                     f"{int(selection) - 42}", f"{int(selection) - 9}", f"{int(selection) - 18}",
  304.                     f"{int(selection) - 36}", f"{int(selection) - 54}", f"{int(selection) - 32}",
  305.                     f"{int(selection) - 50}", f"{int(selection) - 46}"]
  306.     elif current_player == p2:
  307.         calclist = [f"{int(selection) + 7}", f"{int(selection) + 14}", f"{int(selection) + 28}",
  308.                     f"{int(selection) + 42}", f"{int(selection) + 9}", f"{int(selection) + 18}",
  309.                     f"{int(selection) + 36}", f"{int(selection) + 54}", f"{int(selection) + 32}",
  310.                     f"{int(selection) + 50}", f"{int(selection) + 46}"]
  311.     else:
  312.         calclist = ["error"]
  313.  
  314.     # pvision = []
  315.     # for each in calclist:
  316.     #     if each in available_spots and board[int(each)] in available_spots:
  317.     #         pvision.append(int(each))
  318.     # shortened:
  319.     pvision = [int(each) for each in calclist if each in available_spots and board[int(each)] in available_spots]
  320.     pvision.sort()
  321.     # EPIVISION: editted pvision with can_eat
  322.     epvision = []
  323.     for each in pvision:
  324.         if current_player == p1:
  325.             if not can_eat(selection):
  326.                 if int(each) > (int(selection) - 10):
  327.                     epvision.append(each)
  328.             else:
  329.                 epvision.append(each)
  330.         elif current_player == p2:
  331.             if not can_eat(selection):
  332.                 if int(each) < (int(selection) + 10):
  333.                     epvision.append(each)
  334.             else:
  335.                 epvision.append(each)
  336.  
  337.     # FPVISION: final version of epvision, shows the only possible moves allowed by selected pawn.
  338.     fpvision = []
  339.     for each in epvision:
  340.         if current_player == p1:
  341.             if each == int(selection) - 7:
  342.                 fpvision.append(each)
  343.             elif each == int(selection) - 14:
  344.                 if board[int(selection) - 7] == p2:
  345.                     fpvision.append(each)
  346.             elif each == int(selection) - 28:
  347.                 if board[int(selection) - 21] == p2 and board[int(selection) - 7] == p2:
  348.                     fpvision.append(each)
  349.             elif each == int(selection) - 42:
  350.                 if board[int(selection) - 35] == p2 and board[int(selection) - 21] == p2 and board[int(selection) - 7] == p2:
  351.                     fpvision.append(each)
  352.  
  353.             elif each == int(selection) - 9:
  354.                 fpvision.append(each)
  355.             elif each == int(selection) - 18:
  356.                 if board[int(selection) - 9] == p2:
  357.                     fpvision.append(each)
  358.             elif each == int(selection) - 36:
  359.                 if board[int(selection) - 27] == p2 and board[int(selection) - 9] == p2:
  360.                     fpvision.append(each)
  361.             elif each == int(selection) - 54:
  362.                 if board[int(selection) - 45] == p2 and board[int(selection) - 27] == p2 and board[int(selection) - 9] == p2:
  363.                     fpvision.append(each)
  364.  
  365.             elif each == int(selection) - 32:
  366.                 if (int(selection) - 14 in epvision and board[int(selection) - 7] == p2 and board[
  367.                     int(selection) - 14 - 9] == p2) or (
  368.                         int(selection) - 18 in epvision and board[int(selection) - 9] == p2 and board[int(selection) - 18 - 7] == p2):
  369.                     fpvision.append(each)
  370.             elif each == int(selection) - 50:
  371.                 # if (each - 32 available^ and board[int(selection) - 41] == p2) or (each - 36 available^ and board[int(selection) - 43] == p2):
  372.                 if (int(selection) - 14 in epvision and board[int(selection) - 7] == p2 and board[
  373.                     int(selection) - 14 - 9] == p2) or (
  374.                         int(selection) - 18 in epvision and board[int(selection) - 9] == p2 and board[int(selection) - 18 - 7] == p2):
  375.                     if board[int(selection) - 41] == p2:
  376.                         fpvision.append(each)
  377.                 if board[int(selection) - 27] == p2 and board[int(selection) - 9] == p2:
  378.                     if board[int(selection) - 43] == p2:
  379.                         fpvision.append(each)
  380.             elif each == int(selection) - 46:
  381.                 # if (each - 32 available^ and board[int(selection) - 39] == p2) or (each - 28 available^ and board[int(selection) - 37] == p2):
  382.                 if (int(selection) - 14 in epvision and board[int(selection) - 7] == p2 and board[
  383.                     int(selection) - 14 - 9] == p2) or (
  384.                         int(selection) - 18 in epvision and board[int(selection) - 9] == p2 and board[int(selection) - 18 - 7] == p2):
  385.                     if board[int(selection) - 39] == p2:
  386.                         fpvision.append(each)
  387.                 if board[int(selection) - 21] == p2 and board[int(selection) - 7] == p2:
  388.                     if board[int(selection) - 37] == p2:
  389.                         fpvision.append(each)
  390.  
  391.         elif current_player == p2:
  392.             if each == int(selection) + 7:
  393.                 fpvision.append(each)
  394.             elif each == int(selection) + 14:
  395.                 if board[int(selection) + 7] == p1:
  396.                     fpvision.append(each)
  397.             elif each == int(selection) + 28:
  398.                 if board[int(selection) + 21] == p1 and board[int(selection) + 7] == p1:
  399.                     fpvision.append(each)
  400.             elif each == int(selection) + 42:
  401.                 if board[int(selection) + 35] == p1 and board[int(selection) + 21] == p1 and board[int(selection) + 7] == p1:
  402.                     fpvision.append(each)
  403.  
  404.             elif each == int(selection) + 9:
  405.                 fpvision.append(each)
  406.             elif each == int(selection) + 18:
  407.                 if board[int(selection) + 9] == p1:
  408.                     fpvision.append(each)
  409.             elif each == int(selection) + 36:
  410.                 if board[int(selection) + 27] == p1 and board[int(selection) + 9] == p1:
  411.                     fpvision.append(each)
  412.             elif each == int(selection) + 54:
  413.                 if board[int(selection) + 45] == p1 and board[int(selection) + 27] == p1 and board[int(selection) + 9] == p1:
  414.                     fpvision.append(each)
  415.  
  416.             elif each == int(selection) + 32:
  417.                 if (int(selection) + 14 in epvision and board[int(selection) + 7] == p1 and board[
  418.                     int(selection) + 14 + 9] == p1) or (
  419.                         int(selection) + 18 in epvision and board[int(selection) + 9] == p1 and board[int(selection) + 18 + 7] == p1):
  420.                     fpvision.append(each)
  421.             elif each == int(selection) + 50:
  422.                 # if (each + 32 available^ and board[int(selection) + 41] == p1) or (each + 36 available^ and board[int(selection) + 43] == p1):
  423.                 if (int(selection) + 14 in epvision and board[int(selection) + 7] == p1 and board[
  424.                     int(selection) + 14 + 9] == p1) or (
  425.                         int(selection) + 18 in epvision and board[int(selection) + 9] == p1 and board[int(selection) + 18 + 7] == p1):
  426.                     if board[int(selection) + 41] == p1:
  427.                         fpvision.append(each)
  428.                 if board[int(selection) + 27] == p1 and board[int(selection) + 9] == p1:
  429.                     if board[int(selection) + 43] == p1:
  430.                         fpvision.append(each)
  431.             elif each == int(selection) + 46:
  432.                 # if (each + 32 available^ and board[int(selection) + 39] == p1) or (each + 28 available^ and board[int(selection) + 37] == p1):
  433.                 if (int(selection) + 14 in epvision and board[int(selection) + 7] == p1 and board[
  434.                     int(selection) + 14 + 9] == p1) or (
  435.                         int(selection) + 18 in epvision and board[int(selection) + 9] == p1 and board[int(selection) + 18 + 7] == p1):
  436.                     if board[int(selection) + 39] == p1:
  437.                         fpvision.append(each)
  438.                 if board[int(selection) + 21] == p1 and board[int(selection) + 7] == p1:
  439.                     if board[int(selection) + 37] == p1:
  440.                         fpvision.append(each)
  441.     cord_process = True
  442.     display_board()
  443.     print(f"{current_player} selected pawn at {yellow}{selection}{reset}. Can eat: {can_eat(selection)}")
  444.     print(f"P {pvision}")
  445.     print(f"EP {epvision}")
  446.     print(f"FV {fpvision}")
  447.     cord = input(f"Select a coordinate: ")
  448.     while True:
  449.         if not cord.isdigit() or cord not in available_spots:
  450.             cord = input(f"Cord not in {green}{fpvision}{reset}. Try again: ")
  451.             continue
  452.         elif int(cord) not in fpvision:
  453.             cord = input(f"Cord not in {green}{fpvision}{reset}. Try again: ")
  454.             continue
  455.         else:
  456.             break
  457.     # eating process #####################################################################
  458.     if current_player == p1:
  459.         if int(cord) == int(selection) - 7:
  460.             board[int(cord)] = current_player
  461.         elif int(cord) == int(selection) - 14:
  462.             board[int(selection) - 7] = d_board[int(selection) - 7]
  463.             board[int(cord)] = current_player
  464.         elif int(cord) == int(selection) - 28:
  465.             board[int(selection) - 21] = d_board[int(selection) - 21]
  466.             board[int(selection) - 7] = d_board[int(selection) - 7]
  467.             board[int(cord)] = current_player
  468.         elif int(cord) == int(selection) - 42:
  469.             board[int(selection) - 35] = d_board[int(selection) - 35]
  470.             board[int(selection) - 21] = d_board[int(selection) - 21]
  471.             board[int(selection) - 7] = d_board[int(selection) - 7]
  472.         #####
  473.         elif int(cord) == int(selection) - 9:
  474.             board[int(cord)] = current_player
  475.         elif int(cord) == int(selection) - 18:
  476.             board[int(selection) - 9] = d_board[int(selection) - 9]
  477.             board[int(cord)] = current_player
  478.         elif int(cord) == int(selection) - 36:
  479.             board[int(selection) - 27] = d_board[int(selection) - 27]
  480.             board[int(selection) - 9] = d_board[int(selection) - 9]
  481.             board[int(cord)] = current_player
  482.         elif int(cord) == int(selection) - 54:
  483.             board[int(selection) - 45] = d_board[int(selection) - 45]
  484.             board[int(selection) - 27] = d_board[int(selection) - 27]
  485.             board[int(selection) - 9] = d_board[int(selection) - 9]
  486.  
  487.         # diamond
  488.         elif int(cord) == int(selection) - 32:
  489.             left_route = (int(selection) - 14) in fpvision and board[int(selection) - 23] == p2
  490.             right_route = (int(selection) - 18) in fpvision and board[int(selection) - 25] == p2
  491.             if left_route and right_route:
  492.                 choice = None
  493.                 while choice not in [f"{int(selection) - 14}", f"{int(selection) - 18}"]:
  494.                     choice = input(f"Choose between these routes: through {green}{int(selection) - 14}{reset} OR through {green}{int(selection) - 18}{reset}: ")
  495.                 if int(choice) == int(selection) - 14:
  496.                     right_route = False
  497.                 elif int(choice) == int(selection) - 18:
  498.                     left_route = False
  499.             if left_route:
  500.                 board[int(selection) - 7] = d_board[int(selection) - 7]
  501.                 board[int(selection) - 23] = d_board[int(selection) - 23]
  502.                 board[int(cord)] = current_player
  503.             elif right_route:
  504.                 board[int(selection) - 9] = d_board[int(selection) - 9]
  505.                 board[int(selection) - 25] = d_board[int(selection) - 25]
  506.                 board[int(cord)] = current_player
  507.        
  508.         # top left of heart
  509.         elif int(cord) == int(selection) - 50:
  510.             left_route = (int(selection) - 36) in fpvision and board[int(selection) - 43] == p2
  511.             right_route = (int(selection) - 32) in fpvision and board[int(selection) - 41] == p2
  512.             if left_route and right_route:
  513.                 choice = None
  514.                 while choice not in [f"{int(selection) - 36}", f"{int(selection) - 32}"]:
  515.                     choice = input(f"Choose between these routes: through {green}{int(selection) - 36}{reset} OR through {green}{int(selection) - 32}{reset}: ")
  516.                 if int(choice) == int(selection) - 36:
  517.                     right_route = False
  518.                 elif int(choice) == int(selection) - 32:
  519.                     left_route = False
  520.             if left_route:
  521.                 board[int(selection) - 43] = d_board[int(selection) - 43]
  522.                 board[int(selection) - 27] = d_board[int(selection) - 27]
  523.                 board[int(selection) - 9] = d_board[int(selection) - 9]
  524.                 board[int(cord)] = current_player
  525.             elif right_route:
  526.                 left_route = (int(selection) - 14) in fpvision and board[int(selection) - 23] == p2
  527.                 right_route = (int(selection) - 18) in fpvision and board[int(selection) - 25] == p2
  528.                 if left_route and right_route:
  529.                     choice = None
  530.                     while choice not in [f"{int(selection) - 14}", f"{int(selection) - 18}"]:
  531.                         choice = input(f"Choose between these routes: through {green}{int(selection) - 14}{reset} OR through {green}{int(selection) - 18}{reset}: ")
  532.                     if int(choice) == int(selection) - 14:
  533.                         right_route = False
  534.                     elif int(choice) == int(selection) - 18:
  535.                         left_route = False
  536.                 if left_route:
  537.                     board[int(selection) - 41] = d_board[int(selection) - 41]
  538.                     board[int(selection) - 7] = d_board[int(selection) - 7]
  539.                     board[int(selection) - 23] = d_board[int(selection) - 23]
  540.                     board[int(cord)] = current_player
  541.                 elif right_route:
  542.                     board[int(selection) - 41] = d_board[int(selection) - 41]
  543.                     board[int(selection) - 9] = d_board[int(selection) - 9]
  544.                     board[int(selection) - 25] = d_board[int(selection) - 25]
  545.                     board[int(cord)] = current_player
  546.  
  547.         # top right of heart
  548.         elif int(cord) == int(selection) - 46:
  549.             # long way to right
  550.             right_route = (int(selection) - 28) in pvision and board[int(selection) - 37] == p2
  551.             # diamond way
  552.             left_route = (int(selection) - 32) in pvision and board[int(selection) - 39] == p2
  553.             if left_route and right_route:
  554.                 choice = None
  555.                 while choice not in [f"{int(selection) - 28}", f"{int(selection) - 32}"]:
  556.                     choice = input(f"Choose between these routes: through {green}{int(selection) - 28}{reset} OR through {green}{int(selection) - 32}{reset}: ")
  557.                 if int(choice) == int(selection) - 28:
  558.                     left_route = False
  559.                 elif int(choice) == int(selection) - 32:
  560.                     right_route = False
  561.             if right_route:
  562.                 board[int(selection) - 37] = d_board[int(selection) - 37]
  563.                 board[int(selection) - 21] = d_board[int(selection) - 21]
  564.                 board[int(selection) - 7] = d_board[int(selection) - 7]
  565.                 board[int(cord)] = current_player
  566.             elif left_route:
  567.                 left_route = (int(selection) - 14) in fpvision and board[int(selection) - 23] == p2
  568.                 right_route = (int(selection) - 18) in fpvision and board[int(selection) - 25] == p2
  569.                 if left_route and right_route:
  570.                     choice = None
  571.                     while choice not in [f"{int(selection) - 14}", f"{int(selection) - 18}"]:
  572.                         choice = input(f"Choose between these routes: through {green}{int(selection) - 14}{reset} OR through {green}{int(selection) - 18}{reset}: ")
  573.                     if int(choice) == int(selection) - 14:
  574.                         right_route = False
  575.                     elif int(choice) == int(selection) - 18:
  576.                         left_route = False
  577.                 if left_route:
  578.                     board[int(selection) - 39] = d_board[int(selection) - 39]
  579.                     board[int(selection) - 7] = d_board[int(selection) - 7]
  580.                     board[int(selection) - 23] = d_board[int(selection) - 23]
  581.                     board[int(cord)] = current_player
  582.                 elif right_route:
  583.                     board[int(selection) - 39] = d_board[int(selection) - 39]
  584.                     board[int(selection) - 9] = d_board[int(selection) - 9]
  585.                     board[int(selection) - 25] = d_board[int(selection) - 25]
  586.                     board[int(cord)] = current_player
  587.         else:
  588.             board[int(cord)] = current_player
  589.             print(f"{red} WARNING >> End of elif eating <<")
  590.         #################################################################################### p2 eating process:
  591.     elif current_player == p2:
  592.         if int(cord) == int(selection) + 7:
  593.             board[int(cord)] = current_player
  594.         elif int(cord) == int(selection) + 14:
  595.             board[int(selection) + 7] = d_board[int(selection) + 7]
  596.             board[int(cord)] = current_player
  597.         elif int(cord) == int(selection) + 28:
  598.             board[int(selection) + 21] = d_board[int(selection) + 21]
  599.             board[int(selection) + 7] = d_board[int(selection) + 7]
  600.             board[int(cord)] = current_player
  601.         elif int(cord) == int(selection) + 42:
  602.             board[int(selection) + 35] = d_board[int(selection) + 35]
  603.             board[int(selection) + 21] = d_board[int(selection) + 21]
  604.             board[int(selection) + 7] = d_board[int(selection) + 7]
  605.         #####
  606.         elif int(cord) == int(selection) + 9:
  607.             board[int(cord)] = current_player
  608.         elif int(cord) == int(selection) + 18:
  609.             board[int(selection) + 9] = d_board[int(selection) + 9]
  610.             board[int(cord)] = current_player
  611.         elif int(cord) == int(selection) + 36:
  612.             board[int(selection) + 27] = d_board[int(selection) + 27]
  613.             board[int(selection) + 9] = d_board[int(selection) + 9]
  614.             board[int(cord)] = current_player
  615.         elif int(cord) == int(selection) + 54:
  616.             board[int(selection) + 45] = d_board[int(selection) + 45]
  617.             board[int(selection) + 27] = d_board[int(selection) + 27]
  618.             board[int(selection) + 9] = d_board[int(selection) + 9]
  619.        
  620.         # diamond
  621.         elif int(cord) == int(selection) + 32:
  622.             left_route = (int(selection) + 14) in fpvision and board[int(selection) + 23] == p1
  623.             right_route = (int(selection) + 18) in fpvision and board[int(selection) + 25] == p1
  624.             if left_route and right_route:
  625.                 choice = None
  626.                 while choice not in [f"{int(selection) + 14}", f"{int(selection) + 18}"]:
  627.                     choice = input(f"Choose between these routes: through {green}{int(selection) + 14}{reset} OR through {green}{int(selection) + 18}{reset}: ")
  628.                 if int(choice) == int(selection) + 14:
  629.                     right_route = False
  630.                 elif int(choice) == int(selection) + 18:
  631.                     left_route = False
  632.             if left_route:
  633.                 board[int(selection) + 7] = d_board[int(selection) + 7]
  634.                 board[int(selection) + 23] = d_board[int(selection) + 23]
  635.                 board[int(cord)] = current_player
  636.             elif right_route:
  637.                 board[int(selection) + 9] = d_board[int(selection) + 9]
  638.                 board[int(selection) + 25] = d_board[int(selection) + 25]
  639.                 board[int(cord)] = current_player
  640.  
  641.         # top left of heart
  642.         elif int(cord) == int(selection) + 50:
  643.             left_route = (int(selection) + 36) in fpvision and board[int(selection) + 43] == p1
  644.             right_route = (int(selection) + 32) in fpvision and board[int(selection) + 41] == p1
  645.             if left_route and right_route:
  646.                 choice = None
  647.                 while choice not in [f"{int(selection) + 36}", f"{int(selection) + 32}"]:
  648.                     choice = input(f"Choose between these routes: through {green}{int(selection) + 36}{reset} OR through {green}{int(selection) + 32}{reset}: ")
  649.                 if int(choice) == int(selection) + 36:
  650.                     right_route = False
  651.                 elif int(choice) == int(selection) + 32:
  652.                     left_route = False
  653.             if left_route:
  654.                 board[int(selection) + 43] = d_board[int(selection) + 43]
  655.                 board[int(selection) + 27] = d_board[int(selection) + 27]
  656.                 board[int(selection) + 9] = d_board[int(selection) + 9]
  657.                 board[int(cord)] = current_player
  658.             elif right_route:
  659.                 left_route = (int(selection) + 14) in fpvision and board[int(selection) + 23] == p1
  660.                 right_route = (int(selection) + 18) in fpvision and board[int(selection) + 25] == p1
  661.                 if left_route and right_route:
  662.                     choice = None
  663.                     while choice not in [f"{int(selection) + 14}", f"{int(selection) + 18}"]:
  664.                         choice = input(f"Choose between these routes: through {green}{int(selection) + 14}{reset} OR through {green}{int(selection) + 18}{reset}: ")
  665.                     if int(choice) == int(selection) + 14:
  666.                         right_route = False
  667.                     elif int(choice) == int(selection) + 18:
  668.                         left_route = False
  669.                 if left_route:
  670.                     board[int(selection) + 41] = d_board[int(selection) + 41]
  671.                     board[int(selection) + 7] = d_board[int(selection) + 7]
  672.                     board[int(selection) + 23] = d_board[int(selection) + 23]
  673.                     board[int(cord)] = current_player
  674.                 elif right_route:
  675.                     board[int(selection) + 41] = d_board[int(selection) + 41]
  676.                     board[int(selection) + 9] = d_board[int(selection) + 9]
  677.                     board[int(selection) + 25] = d_board[int(selection) + 25]
  678.                     board[int(cord)] = current_player
  679.  
  680.         # top right of heart
  681.         elif int(cord) == int(selection) + 46:
  682.             # long way to right
  683.             right_route = (int(selection) + 28) in pvision and board[int(selection) + 37] == p1
  684.             # diamond way
  685.             left_route = (int(selection) + 32) in pvision and board[int(selection) + 39] == p1
  686.             if left_route and right_route:
  687.                 choice = None
  688.                 while choice not in [f"{int(selection) + 28}", f"{int(selection) + 32}"]:
  689.                     choice = input(f"Choose between these routes: through {green}{int(selection) + 28}{reset} OR through {green}{int(selection) + 32}{reset}: ")
  690.                 if int(choice) == int(selection) + 28:
  691.                     left_route = False
  692.                 elif int(choice) == int(selection) + 32:
  693.                     right_route = False
  694.             if right_route:
  695.                 board[int(selection) + 37] = d_board[int(selection) + 37]
  696.                 board[int(selection) + 21] = d_board[int(selection) + 21]
  697.                 board[int(selection) + 7] = d_board[int(selection) + 7]
  698.                 board[int(cord)] = current_player
  699.             elif left_route:
  700.                 left_route = (int(selection) + 14) in fpvision and board[int(selection) + 23] == p1
  701.                 right_route = (int(selection) + 18) in fpvision and board[int(selection) + 25] == p1
  702.                 if left_route and right_route:
  703.                     choice = None
  704.                     while choice not in [f"{int(selection) + 14}", f"{int(selection) + 18}"]:
  705.                         choice = input(f"Choose between these routes: through {green}{int(selection) + 14}{reset} OR through {green}{int(selection) + 18}{reset}: ")
  706.                     if int(choice) == int(selection) + 14:
  707.                         right_route = False
  708.                     elif int(choice) == int(selection) + 18:
  709.                         left_route = False
  710.                 if left_route:
  711.                     board[int(selection) + 39] = d_board[int(selection) + 39]
  712.                     board[int(selection) + 7] = d_board[int(selection) + 7]
  713.                     board[int(selection) + 23] = d_board[int(selection) + 23]
  714.                     board[int(cord)] = current_player
  715.                 elif right_route:
  716.                     board[int(selection) + 39] = d_board[int(selection) + 39]
  717.                     board[int(selection) + 9] = d_board[int(selection) + 9]
  718.                     board[int(selection) + 25] = d_board[int(selection) + 25]
  719.                     board[int(cord)] = current_player
  720.         else:
  721.             board[int(cord)] = current_player
  722.             print(f"{red} WARNING >> End of elif eating <<")
  723.  
  724.     board[int(selection)] = d_board[int(selection)]
  725.     cord_process = False
  726.  
  727.  
  728. game_is_active = True
  729. current_player = p1
  730.  
  731. while game_is_active:
  732.     select_pawn()
  733.     check_for_win()
  734.     switch_player()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement