No, it wouldn’t defect against itself, because UX will call the same eval(“return p”) twice:
UX(X) = { return PDPayoffMatrix[eval(X), eval(X)]; }
The payoff with p=cooperate is greater, so the agent will cooperate.
EDIT: Sorry, that was all wrong, and missed your point. Thinking now...
No, it wouldn’t defect against itself, because UX will call the same eval(“return p”) twice:
UX(X) = { return PDPayoffMatrix[eval(X), eval(X)]; }
The payoff with p=cooperate is greater, so the agent will cooperate.
EDIT: Sorry, that was all wrong, and missed your point. Thinking now...