CodinGame / codingame-game-engine

CodinGame Engine
https://www.codingame.com
MIT License
110 stars 41 forks source link

Why don't you check if an attribute changed before updating an entity #48

Closed Butanium closed 2 years ago

Butanium commented 2 years ago

Hello, I was wondering why you don't check if an attribute is actually the same before changing it.

For example if myEntity is already in x = 10 why does myEntity.setX(10) update the entity state in the game.json ? A simple

if (this.x = x) {return this} 

Would save some space in game.json or line of code for those who have big games and have to be careful about what they add in game.json https://github.com/CodinGame/codingame-game-engine/blob/9a9e9718c7f346c67808e5d221eee1d6c9c8e397/engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/Entity.java#L93

CGjupoulton commented 2 years ago

I'm confused, this does not happen. I must misundertand your example. If you keep setting x to 10 over and over, the game.json will be practivally empty

Butanium commented 2 years ago

When I get back to clash of bots I'll tell you if I can reproduce it, maybe I misunderstood the game.json when I read it

CGjupoulton commented 2 years ago

When I get back to clash of bots I'll tell you if I can reproduce it, maybe I misunderstood the game.json when I read it

Sure, keep me posted, will be happy to help