Exemplo n.º 1
0
 public ActionPath(ScoredAction action, ActionPath actionPath)
 {
     actions = new List <ScoredAction> {
         action
     };
     actions.AddRange(actionPath.actions);
 }
Exemplo n.º 2
0
        private void UpdateScore(ScoredAction action)
        {
            switch (action)
            {
            case ScoredAction.Move:
                if (scoreSinceLastFuel < FuelCollected)
                {
                    Score--;    //+1 each move up to the tail length
                    scoreSinceLastFuel++;
                }
                break;

            case ScoredAction.CollectFuel:
                scoreSinceLastFuel = 0;
                Score += 2 * FuelCollected;
                break;
            }
        }
Exemplo n.º 3
0
    // result: Best Action-Score pair on the called Board
    public void AICallback(ActionPath result, MoveSuggestor ms, int tested, int all)
    {
        ScoredAction branchBestSoFar = actionPathLookup[ms.ID].actions[0];

        ActionPath actionPathToTest = result.AppendAtFront(branchBestSoFar);

        if (pruningOn && pruneThisRound && !branchBestSoFar.Invalid)
        {
            if (actionPathToTest.GetValueFor(GetPlayerID()) >= alpha)
            {
                actionsToTry.Clear();
            }
        }
        bestActionPath = bestActionPath.GetIfBetter(actionPathToTest, GetPlayerID(), this);
        startedSubtasks--;

        // Info
        finished++;
        this.tested += tested;
        this.all    += all;
    }
Exemplo n.º 4
0
    public ScoredAction GetIfBetter(ScoredAction scoredAction, MoveSuggestor invoker)
    {
        if (Invalid)
        {
            return(scoredAction);
        }
        if (scoredAction.Invalid)
        {
            return(this);
        }

        if (Score > scoredAction.Score)
        {
            return(this);
        }
        else
        {
            // If the Actions are identical
            if (Score == scoredAction.Score)
            {
                ScoredAction randomChoice = Random.Range(0, 2) == 0 ? this : scoredAction;

                // Priorities, Rules
                if (Action.IsPass())
                {
                    return(randomChoice);
                }
                if (Action.Move.GetMoveType(invoker.board) == MoveType.Capture)
                {
                    return(this);    // Capture if possible
                }
                return(randomChoice);
            }
            return(scoredAction);
        }
    }