I'm trying to find a short story I remember reading in the 1980s. It concerns a man trying to deactivate a military robot which has remained active after the end of a war, due to damage to its communications equipment(?). It attacks him and he takes refuge in a cave. At one point his spacesuit is damaged and he fills the leg with water and freezes it. I think it is set on Earth's moon, but I could be wrong about that.