Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help me out by providing a code that I can directly add to my code as I'm not sure what should I do about
please help me out by providing a code that I can directly add to my code as I'm not sure what should I do about it
rule 7
please do this based on my code shown below
that is all information I received to code the method play_move further more I can provide the test cases and the expected output
the code is in python and following is the example game play
In the Board class, define a method play_move(self, colour_name, coords) that plays a move according rule \#7 (see Background Informatiori). For coords and colour_name, see Task 2. If the point at the given coordinates is not empty, raise an AssertionError with message "illegal move: point not empty". Consider this example: The three black points all reach empty according to the definition: From each of them there is a path of black points to the point F9, which is empty. After White plays F9, Black's three stones don't reach empty any more, so they are removed: Note that the definition of reaching (rule \#3) taks about a path of vertically or horizontally adjacent points. This is visualised on the Go board by following the lines. The two points B8 and F8 are not adjacent to the chain of three black stones. Here's another example for the application of rule \#7. Consider this position: Here, all black stones reach empty, namely the point marked by the triangle. If Black now plays on that point, rule \#7 states that first White is cleared (which results in removing nothing, because each white stone reaches empty) and then Black is cleared. This removes all black stones because none of them reach empty after the move: with open(filename, "wt") as f rom string import ascii_uppercase as letters lass Board: Dictionary created for the colours and the respected symbols points={E:,B:,W:0} Constructor def_to_row_and_column (self, coords): \# destructure coordinates like "B2" to "B" and 2 alpha, num = coords colnum =ord( alpha )ord( A A' )+1 rownum = self.size int ( num )+1 assert 1 rownum = self. size, "row out of range" assert 1 colnum self. size, 'column out of range' return rownum, colnum def set_colour(self, coords, colour_name): rownum, colnum = self._to_row_and_column(coords) assert len(coords) ==2 or len(coords)==3, "invalid coordinates" assert colour_name in self.points, "invalid colour name" self.grid[rownum 1][ colnum 1]= colour_name def get_colour(self, coords): rownum, colnum = self._to_row_and_column (coords) return self.grid[rownum - 1] [colnum - 1] def to_strings(self): padding = lines =[] for r, row in enumerate(self.grid): if self.from_strings: lines.append (''.join(self.from_strings[r])) else: Zines.append(', join(self.points [x] for x in row)) return lines \# return join(self.to_int [x]] for line in self.grid for x in line) def set_from_integer(self, integer_encoding): \[ \begin{array}{l} n=\text { int(integer_encoding) } \\ \text { list1 = [] } \\ p=[] \\ m=[] \\ t=[] \end{array} \] while n!=0 : rem=n%3 list1. append (rem) n=n1/3 List1.reverse() list1 =["." if item =0 else item for item in list1] def set_from_integer(self, integer_encoding): def fill_reaching(self, colour_name, reach_name, visited, r,c) : new_list =[] new_list2 =[] for x in self.from_strings: for y in x : if y==11. def fill,reaching(self, colour-name, reach, name, visited, r,c) : newlist=[]new2ist2=[] for x in self. fromstrings: for y in x : if y=en." y="E" elif y=nn0n: y="B elif y== : y=W1" new list, append (y) for i in range (, len (new list), self. size): new list2. append (new_-list[i:i + self.size]) self.grid = new_list? if r self.size or c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started