StevensSEC / pokemonbattlelib

A portable library for accurately simulating Pokemon battles.
GNU General Public License v3.0
12 stars 2 forks source link

Agents are not given copies of moves. #294

Closed dyc3 closed 3 years ago

dyc3 commented 3 years ago

Current Behavior

Agents are not given copies of moves. Agents should not receive ground truth pointers to the Pokemon's moves.

To Reproduce Code snippet to reproduce the problem (if applicable)

It("should never receive a ground truth reference to pokemon in the battle", func() {
        b := NewBattle()
        a1 := newRcAgent()
        _a1 := Agent(a1)
        a2 := Agent(funkyAgent(func(ctx *BattleContext) Turn {
            real := b.getPokemon(ctx.Opponents[0])
            Expect(ctx.Opponents[0].Pokemon).ToNot(BeIdenticalTo(real))
            Expect(ctx.Opponents[0].Pokemon.Moves[0]).ToNot(BeIdenticalTo(real.Moves[0]))
            return FightTurn{Move: 0, Target: ctx.Opponents[0]}
        }))
        party1 := NewOccupiedParty(&_a1, 0, GeneratePokemon(PkmnCharmander, defaultMoveOpt))
        party2 := NewOccupiedParty(&a2, 1, GeneratePokemon(PkmnSquirtle, defaultMoveOpt))
        b.AddParty(party1, party2)
        Expect(b.Start()).To(Succeed())
        a1 <- FightTurn{
            Move: 0,
            Target: target{
                party:     1,
                partySlot: 0,
            },
        }
        b.SimulateRound()
    })

Expected Behavior

Expected Moves to be copied when given to an Agent.

Additional context Add any other context about the problem here.