The-International-Screeps-Bot / The-International-Open-Source

An automated bot for the coding game Screeps.com
MIT License
104 stars 35 forks source link

[isAlly] Towers and creeps attacking allies #755

Closed realacesu closed 10 months ago

realacesu commented 10 months ago

Commit or otherwise version of the bot

Development Branch fb95b3319195d2c47a124194aae420cf911f7c5e

Describe the bug

IsAlly seems to be incorrectly implemented and/or called incorrectly resulting in towers and creeps attacking allies.

export function isAlly(playerName: string) {
    const playerMemory = Memory.players[playerName]
    if (!playerMemory) return false

    if (playerMemory[PlayerMemoryKeys.relationship] !== 'ally') return false
    return true
}

PlayerMemory relationship key is not set with the current implementation.

Expected behaviour

IsAlly returns if the owner of an object is an ally PlayerMemory relationship key is also not set with the current implementation.

Potential fix

review isAlly function calls and setting the playerMemoryKey 'relationship' on initialize.

Applicable media

If using default settings and are on shard2, check Memory -> players -> MarvinTMB for index 5 AKA relationship.

https://i.imgur.com/vawoGSt.png

CarsonBurke commented 10 months ago

fix by #756