Most bacteria have two distinct lifestyles: solitary-planktonic and aggregated surface-attached biofilm. There is an inherent fitness tradeoff between these two lifestyles: though planktonic cells typically grow faster, bacteria in biofilms gain a higher resistance to various stresses including desiccation, antibiotic and predation. Here we ask if and to what extent smart lifestyle-transition decisions can provide fitness advantage in environments with a periodic stress. To study the impact of such decision making on fitness, we use an individual-based modeling approach where foraging planktonic cells colonize a surface under wetting and drying cycles. Such cycles are common in the largest terrestrial microbial habitats – soil, roots, and leaf surfaces – that are not constantly saturated with water and experience dry periods on a daily basis. We compared different surface-attachment strategies (planktonic-biofilm transitions), and analyzed the emerging spatio-temporal dynamics of surface colonization and population yield. We demonstrate that at a range of environmental conditions relevant to many terrestrial microbial habitats, even a simple strategy, such as preferential attachment (PA) to existing aggregates above a given size, carries a large fitness advantage over any stochastic attachment. The improvement in fitness is due to a more optimal balance between growth and survival resulting from the aggregate-size distribution dynamics controlled by the decisions of individual-cells. Specifically, we show that PA can confer large fitness advantage in oligotrophic environments, such as soil and leaf surface, where large desiccation-protected aggregates are unlikely to be formed by clonal growth only. The feasibility and benefits of PA in the context of bacterial surface colonization in environments with a period stress will be explored in future experiments.