A new method for finding the global extremum of functions of many variables under interval constraints is proposed. The method simulates the process of foraging for edible mushrooms (Boletus edulis, Leccinum aurantiacum, Leccinum scabrum, Cantharellus cibarius, Pleurotus, etc.) in a forest by a group of mushroom pickers. The algorithm includes a forest exploration stage (a set of feasible solutions) to find mushroom sites and an exploitation stage, during which previously identified mushroom sites are intensively explored by implementing various movement strategies for the mushroom pickers. The method is classified as both bioinspired metaheuristic algorithms and multi-agent evolutionary algorithms. Its effectiveness is demonstrated using eight typical problems of static parametric optimization of technical systems: pressure vessel problem, welded beam optimization problem, tension/compression spring design problem, gear train optimization design, speed reducer problem, three-bar truss problem, tubular column design optimization, flapping wing design optimization. Experience solving these problems allowed us to formulate recommendations for defining the hyperparameters of the proposed optimization method. The primary goal of the development was to apply this new bio-inspired optimization algorithm to three optimal control problems for discrete dynamic systems: optimal control of a single trajectory, a bundle of trajectories of a deterministic system starting from a given set of initial states, and optimal control of stochastic systems.