The init function should take arguments for the grid size (rows, columns, both ints), the initial density of each species (a tuple of floats), the neighborhood type ("neumann" or "moore"), the parameters in the form of a dictionary, and the seed for the generator. It should assign the parameters dictionary to the params variable, create the generator object and assign it to the generator variable, as well as create the 2D array of zeros based on the grid size and assign it to the grid variable. This grid should then be filled with states dependent on the density tuple. Iterate over the elements i of this tuple, filling grid_size * density[i] elements of the grid with state i+1. Non-zero cell states should not be overwritten, ensuring that the specified percentage of the grid is filled with that state. It should also check if the neighborhood argument corresponds with a known neighborhood and return an error otherwise.
0 commit comments