Many optical applications require accurate control over a beam's spatial intensity profile, in particular, achieving uniform irradiance across a target area can be critically important for nonlinear optical processes such as laser machining. This paper introduces a novel control algorithm for Digital Micromirror Devices (DMDs) that simultaneously and adaptively modulates both the intensity and the spatial intensity profile of an incident beam with random and intricate intensity variations in a single step. The algorithm treats each micromirror within the DMD as an independent Bernoulli distribution characterized by a learnable parameter. By integrating reinforcement learning with fully convolutional neural networks, we demonstrate that the control of 65,536 (256 × 256) micromirrors in a DMD can be achieved with modest computational expense. Furthermore, we implement the Error Diffusion (ED) algorithm as a sampling method and show that an incident beam with random and intricate intensity variations can be modulated to a predefined shape with high uniformity in intensity, both in simulated and experimental environments.