I removed the myloss() function altogether and fixed the playgame() function so that it can accept a tensor as an argument. The training loop now looks like this:
m = TwoLayerNet()
loss_fn = nn.MSELoss()
optimizer = optim.Adam(m.parameters(), lr=0.01)

training_epochs = 10
fitnessgoal = torch.tensor(1200, dtype=torch.float)
blanktensor = torch.zeros([1, 438])

   
for i in range(training_epochs):

    fpass = m(blanktensor)

    loss = loss_fn(playgame(fpass), fitnessgoal)
    loss.requires_grad = True
    print(i,fitness,loss)
    print(loss.grad)

    optimizer.zero_grad()

    loss.backward()

    optimizer.step()

Unfortunately, the result is pretty much the same. 10 epochs:
0 tensor(744.) tensor(207936., requires_grad=True)
None
1 tensor(744.) tensor(207936., requires_grad=True)
None
2 tensor(744.) tensor(207936., requires_grad=True)
None
3 tensor(744.) tensor(207936., requires_grad=True)
None
4 tensor(744.) tensor(207936., requires_grad=True)
None
5 tensor(744.) tensor(207936., requires_grad=True)
None
6 tensor(744.) tensor(207936., requires_grad=True)
None
7 tensor(744.) tensor(207936., requires_grad=True)
None
8 tensor(744.) tensor(207936., requires_grad=True)
None
9 tensor(744.) tensor(207936., requires_grad=True)
None

The loss never changes, and gradient is None. I thought that perhaps the playgame() function was still to blame for this, so I added this to the end of it:
fitness = torch.tensor(land, dtype=torch.float)
fitness.requires_grad = True

return(fitness)

That resulted in the error “you can only change requires_grad flags of leaf variables”. I don’t exactly know what this means, but it seems that running a tensor through the playgame() function is disconnecting things somehow. Maybe Pytorch wasn’t meant to be used like this.