The nesting problem, also known as the packing problem, or the bin packing problem, is a classic and popular NP-hard problem that is widely used in industries such as metal cutting, leather, and glass. The current mainstream nesting solution algorithm is a hybrid algorithm combining intelligent sequencing and heuristic positioning, which has the problems of long solution time and low optimization efficiency. Inspired by the machine learning method represented by reinforcement learning, a reinforcement learning method based on Sarsa-learning is proposed in this paper to solve the two-dimensional(2D) irregular pieces nesting problem, and a reward evaluation and update model is established. The experimental results show that the machine learning method based on Sarsa-learning can achieve a certain nesting optimization effect and has great application potential.