Fungi, in particular, basidiomycetous fungi, are very successful in colonizing microconfined mazelike networks (for example, soil, wood, leaf litter, plant and animal tissues), a fact suggesting that they may be efficient solving agents of geometrical problems. We therefore evaluated the growth behavior and optimality of fungal space-searching algorithms in microfluidic mazes and networks. First, we found that fungal growth behavior was indeed strongly modulated by the geometry of microconfinement. Second, the fungus used a complex growth and space-searching strategy comprising two algorithmic subsets: 1) long-range directional memory of individual hyphae and 2) inducement of branching by physical obstruction. Third, stochastic simulations using experimentally measured parameters showed that this strategy maximizes both survival and biomass homogeneity in microconfined networks and produces optimal results only when both algorithms are synergistically used. This study suggests that even simple microorganisms have developed adequate strategies to solve nontrivial geometrical problems.