mwg API
    Preparing search index...

    Function scoreWith

    • A view collapsed into the one number a mind compares, according to what that mind cares about.

      Parameters

      Returns number

      import { scoreWith, type ScoreView } from '@datamoc/mw_games/ai';

      const view: ScoreView = { own: 10, allies: 4, enemies: -2, seen: 3 };

      console.log(scoreWith(view, { own: 1, allies: 0, enemies: 0 })); // 10 - out for itself
      console.log(scoreWith(view, { own: 0, allies: 1, enemies: 0 })); // 4 - holds for the line
      console.log(scoreWith(view, { own: 1, allies: 1, enemies: -1 })); // 16 - the enemy is the point