private IEnumerator DoMove(Vector3Int from, Vector3Int to)
    {
        switch (CoordinateUtils.CubeDistance(from, to))
        {
        case 1:
            yield return(DoSplitMove(to));

            break;

        case 2:
            yield return(DoJumpMove(from, to));

            break;
        }

        UpdateGemCountersText();
        CheckWinner();
        SwitchPlayer();

        if (Settings.GameMode == GameMode.PvC && _currentPlayer == GemType.Blue)
        {
            var aiMove = Ai.GetMove(new Board(
                                        GridManager.Instance.Grid(),
                                        GemPlacementManager.Instance.GetGemCoordinates(GemType.Red),
                                        GemPlacementManager.Instance.GetGemCoordinates(GemType.Blue)));
            yield return(DoMove(aiMove.From, aiMove.To));
        }

        HighlightCurrentPlayerGems();

        _moveInProgress = false;
    }
Example #2
0
 private static List <KeyValuePair <AiMove, int> > Estimate(Board board, List <AiMove> moves)
 {
     return(moves.Select(move => {
         var value = CoordinateUtils.CubeDistance(move.From, move.To) == 1 ? 1 : 0;
         var enemySwapCount = board.RedGemsCountAround(move.To);
         value += enemySwapCount;
         return new KeyValuePair <AiMove, int>(move, value);
     }).ToList());
 }
 private static bool InSplitRange(Vector3Int from, Vector3Int to)
 {
     return(CoordinateUtils.CubeDistance(from, to) == 2);
 }