With growing energy demand and increasing environmental concerns, optimizing energy scheduling is crucial for microgrids, as efficient and flexible energy systems. This paper proposes an innovative multi-agent reinforcement learning algorithm to address microgrid energy scheduling. This algorithm incorporates a dynamic weight allocation mechanism, enabling agents to flexibly adjust decision weights based on real-time changes in energy supply and demand, improving the adaptability of scheduling strategies. Furthermore, a reward function based on historical data and real-time status is designed to guide agents in learning optimal energy scheduling strategies. To validate the algorithm's effectiveness, a microgrid energy scheduling simulation platform was constructed to simulate energy production, consumption, and storage in various scenarios. Experimental results show that, compared with traditional algorithms, the proposed algorithm can improve microgrid energy efficiency by an average of 15% and reduce operating costs by 12%. In scenarios with a high proportion of renewable energy, the algorithm effectively reduces energy waste and increases renewable energy consumption by 20%. Furthermore, stability analysis demonstrates that the algorithm maintains stable scheduling performance in the face of energy supply and demand uncertainties, showing strong robustness. This study provides a new solution for microgrid energy scheduling, helping to improve its overall performance and sustainability.