K-nearest Multi-agent Deep Reinforcement Learning for Collaborative Tasks with a Variable Number of Agents