To address the problem of task allocation in scenarios with dynamic task introduction and dynamically changing rewards, a distributed multi-agent task allocation algorithm named I_GRAPE was proposed based on anonymous hedonic games. The I_GRAPE algorithm was designed by integrating a Q-learning-based multi-objective weight adaptation strategy with a log-linear learning method. Agents assigned to the same task were regarded as a coalition, thereby transforming the task allocation problem into a coalition formation game, with the objective of maximizing system utility while minimizing the moving distance of agents and the time cost required to complete tasks. Experimental results demonstrate that the I_GRAPE algorithm achieves satisfactory performance in multi-agent task allocation, with low costs in terms of both moving distance and task completion time. Compared with classical task allocation algorithms, the comprehensive performance of I_GRAPE is improved by 5.85% to 19.14%. The superiority and stability of the I_GRAPE algorithm in practical applications are preliminarily validated.