This is a short fiction, probably a novelette. I read it not so many years ago (but still BC, I mean, before Covid) in a collection. But I think it was a very old collection.

The main character is a sentient, monstrous war machine. By construction, it is limited in its displacement (clearly a very wise precaution of its makers). It already went through a battle with enemies whom he destroyed, but was damaged in the battle. The worst damage is the receptor that was supposed to recognise a signal sent by people on "his side" to identify themselves. So when a party of "his side" comes after the battle to repair it, unable to recognise the signal, it attacks them. All are killed but one who manages to hide in a cave. From what follows it appears the survivor is the one who knows the machine best. Having no news of the first party, a second one comes to find out what happened. They carefully stay out of range of the machine's weapons and manage to communicate with the survivor. The latter has understood what went wrong and tells them to destroy the machine. But it is very expensive, and the second party tries to find another way. While they dither, the sentient machine, which is intelligent, finds a way (that his makers did not imagine) to extend the range of its weapons, or maybe to extend its own displacement limit, I forgot which. In that way it manages to destroy the second party who thought they were far enough to be safe. I am not sure if it finally kills the survivor of the first party, or if the latter dies of his wounds and/or exhaustion. But in the end the machine is alone.

  • 2
    Probable duplicate: I Made You.
    – JRE
    Oct 13, 2023 at 7:53
  • @Valorum I checked the box that opens when one types and it did not appear. Though of course this automatic search is not perfect. I have already asked some dupes even though I also had checked that box before posting the question.
    – Alfred
    Oct 13, 2023 at 7:54
  • @JRE You are right ! I originally forgot it was on the Moon, but now I remember.
    – Alfred
    Oct 13, 2023 at 7:56
  • @Valorum JRE is better than your automatic research. LOL
    – Alfred
    Oct 13, 2023 at 7:56
  • @Alfred - You get an upvote for asking a nice full question though, and you've found your story, so that's a double-win.
    – Valorum
    Oct 13, 2023 at 7:58