예제 #1
0
파일: Fish.cs 프로젝트: bash/Wator
        private IAction? WithRandomUnoccupiedCell(IOrganismEnvironment environment,
            UnoccupiedCellMapper unoccupiedCellMapper)
        {
            var unoccupiedNeighbours = environment.GetFreeNeighbours().ToList();

            if (unoccupiedNeighbours.Count == 0)
            {
                return null;
            }

            var destination = RandomElementPicker.PickRandomElement(unoccupiedNeighbours);

            return unoccupiedCellMapper(destination);
        }
예제 #2
0
파일: Reproducer.cs 프로젝트: bash/Wator
        private IAction?Reproduce(OrganismKind ownKind, IOrganismEnvironment environment)
        {
            var unoccupiedNeighbours = environment.GetFreeNeighbours().ToList();

            if (unoccupiedNeighbours.Count == 0)
            {
                return(null);
            }

            var destination = RandomElementPicker.PickRandomElement(unoccupiedNeighbours);
            var clone       = Organism.Clone();

            return(new Copy(destination, clone, ownKind));
        }