



"""simple docstring"""






from __future__ import annotations

lowerCAmelCase__              =							list[tuple[int, int]]

lowerCAmelCase__              =							[
    [0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 0, 0, 0],  # 0 are free path whereas 1's are obstacles
    [0, 0, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 0],
    [1, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 0, 0],
]

lowerCAmelCase__              =							([-1, 0], [0, -1], [1, 0], [0, 1])  # up, left, down, right






class 			__snake_case			:




  def __init__(					self	:		Optional[Any]		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		float		,   __lowerCAmelCase	:		Node | None		,   ):






         """simple docstring"""






         _lowerCamelCase		:							str            =					pos_x
         _lowerCamelCase		:							Optional[Any]            =					pos_y
         _lowerCamelCase		:							List[Any]            =					(pos_y, pos_x)
         _lowerCamelCase		:							Optional[Any]            =					goal_x
         _lowerCamelCase		:							List[Any]            =					goal_y
         _lowerCamelCase		:							str            =					g_cost
         _lowerCamelCase		:							List[Any]            =					parent
         _lowerCamelCase		:							Optional[int]            =					self.calculate_heuristic()




  def 		SCREAMING_SNAKE_CASE							(					self	:		Optional[Any]						):






         """simple docstring"""






         _lowerCamelCase		:							List[Any]            =					abs(self.pos_x - self.goal_x						)
         _lowerCamelCase		:							str            =					abs(self.pos_y - self.goal_y						)
         return dx + dy




  def __lt__(					self	:		Any		,   __lowerCAmelCase	:		Dict						):






         """simple docstring"""






         return self.f_cost < other.f_cost






class 			__snake_case			:




  def __init__(					self	:		Optional[Any]		,   __lowerCAmelCase	:		tuple[int, int]		,   __lowerCAmelCase	:		tuple[int, int]						):






         """simple docstring"""






         _lowerCamelCase		:							Any            =					Node(start[1]		,   start[0]		,   goal[1]		,   goal[0]		,   0		,   __lowerCAmelCase						)
         _lowerCamelCase		:							Tuple            =					Node(goal[1]		,   goal[0]		,   goal[1]		,   goal[0]		,   9_9_9_9_9		,   __lowerCAmelCase						)

         _lowerCamelCase		:							Optional[int]            =					[self.start]
         _lowerCamelCase		:							list[Node]            =					[]

         _lowerCamelCase		:							Dict            =					False




  def 		SCREAMING_SNAKE_CASE							(					self	:		Any						):






         """simple docstring"""






         while self.open_nodes:
                # Open Nodes are sorted using __lt__
                self.open_nodes.sort()
                _lowerCamelCase		:							Union[str, Any]            =					self.open_nodes.pop(0						)

                if current_node.pos == self.target.pos:
                       _lowerCamelCase		:							List[str]            =					True
                       return self.retrace_path(__lowerCAmelCase						)

                self.closed_nodes.append(__lowerCAmelCase						)
                _lowerCamelCase		:							Optional[Any]            =					self.get_successors(__lowerCAmelCase						)

                for child_node in successors:
                       if child_node in self.closed_nodes:
                              continue

                       if child_node not in self.open_nodes:
                              self.open_nodes.append(__lowerCAmelCase						)
                       else:
                              # retrieve the best current path
                              _lowerCamelCase		:							Union[str, Any]            =					self.open_nodes.pop(self.open_nodes.index(__lowerCAmelCase						)						)

                              if child_node.g_cost < better_node.g_cost:
                                     self.open_nodes.append(__lowerCAmelCase						)
                              else:
                                     self.open_nodes.append(__lowerCAmelCase						)

         if not self.reached:
                return [self.start.pos]
         return None




  def 		SCREAMING_SNAKE_CASE							(					self	:		Any		,   __lowerCAmelCase	:		Node						):






         """simple docstring"""






         _lowerCamelCase		:							str            =					[]
         for action in delta:
                _lowerCamelCase		:							Optional[int]            =					parent.pos_x + action[1]
                _lowerCamelCase		:							Tuple            =					parent.pos_y + action[0]

                if not (0 <= pos_x <= len(grid[0]						) - 1 and 0 <= pos_y <= len(__lowerCAmelCase						) - 1):
                       continue

                if grid[pos_y][pos_x] != 0:
                       continue

                successors.append(
                    Node(
                        __lowerCAmelCase		,   __lowerCAmelCase		,   self.target.pos_y		,   self.target.pos_x		,   parent.g_cost + 1		,   __lowerCAmelCase		,   )						)
         return successors




  def 		SCREAMING_SNAKE_CASE							(					self	:		Tuple		,   __lowerCAmelCase	:		Node | None						):






         """simple docstring"""






         _lowerCamelCase		:							Union[str, Any]            =					node
         _lowerCamelCase		:							Tuple            =					[]
         while current_node is not None:
                path.append((current_node.pos_y, current_node.pos_x)						)
                _lowerCamelCase		:							List[str]            =					current_node.parent
         path.reverse()
         return path


if __name__ == "__main__":
   lowerCAmelCase__              =							(0, 0)
   lowerCAmelCase__              =							(len(grid) - 1, len(grid[0]) - 1)
   for elem in grid:
      print(elem)

   print('''------''')

   lowerCAmelCase__              =							GreedyBestFirst(init, goal)
   lowerCAmelCase__              =							greedy_bf.search()
   if path:
      for pos_x, pos_y in path:
         lowerCAmelCase__              =							2

      for elem in grid:
         print(elem)








"""simple docstring"""

import argparse


a							      =     '''docs/source/_static/js/custom.js'''






def 		_snake_case	(   _snake_case				:   Dict				)       ->   Any:






      '''simple docstring'''


      with open(_snake_case							,    encoding='utf-8'							,    newline='\n'				) as f:
            _A     =  f.readlines()
      _A     =  0

      # First let's put the right version
      while not lines[index].startswith('const stableVersion ='				):
            index += 1
      _A     =  F'''const stableVersion = "v{version}"\n'''

      # Then update the dictionary
      while not lines[index].startswith('const versionMapping = {'				):
            index += 1

      # We go until the end
      while not lines[index].startswith('}'				):
            index += 1
      # We add the new version at the end
      lines[index - 1] += F'''    "v{version}": "v{version}",\n'''

      with open(_snake_case							,    'w'							,    encoding='utf-8'							,    newline='\n'				) as f:
            f.writelines(_snake_case				)


if __name__ == "__main__":
       a							      =     argparse.ArgumentParser()
       parser.add_argument('''--version''', help='''Release version.''')
       a							      =     parser.parse_args()
       update_custom_js(args.version)

