Class AIPlayer

  • All Implemented Interfaces:
    ICreditor, IAIPlayer, ICitizen, IPlayer, IShipOwner

    @Component("aiPlayer")
    @Scope("prototype")
    public class AIPlayer
    extends Player
    implements IAIPlayer
    Implementation of an artificial intelligence player.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2011 Created on Sep 17, 2011
    • Constructor Detail

      • AIPlayer

        public AIPlayer​(ICity homeTown,
                        java.time.LocalDateTime birthDate,
                        ICompany company)
    • Method Detail

      • getPersonalData

        private static PersonalData getPersonalData​(ICity homeTown,
                                                    java.time.LocalDateTime birthDate)
      • getRandomFirstName

        private static java.lang.String getRandomFirstName()
      • getRandomLastName

        private static java.lang.String getRandomLastName()
      • getNextTradeStep

        public ITradeStep getNextTradeStep​(INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Retrieve the next trade step that should be executed and remove it from the list.
        Specified by:
        getNextTradeStep in interface IAIPlayer
        Parameters:
        vessel - for which the next trade step should be checked.
        Returns:
        next trade step for the vessel
      • hasMoreTradeSteps

        public boolean hasMoreTradeSteps​(INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Check if there are further trade steps.
        Specified by:
        hasMoreTradeSteps in interface IAIPlayer
        Parameters:
        vessel - which should be checked.
        Returns:
        true if there are more trade steps defined for vessel
      • addTradeStep

        public void addTradeStep​(ITradeStep tradeStep,
                                 INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Add a new trade step at the end of the list.
        Specified by:
        addTradeStep in interface IAIPlayer
        Parameters:
        tradeStep - to be added.
        vessel - for which the step should be added.
      • injectTradeStep

        public void injectTradeStep​(ITradeStep tradeStep,
                                    INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Inject a trade step at the beinning of the task list for the vessel
        Specified by:
        injectTradeStep in interface IAIPlayer
        Parameters:
        tradeStep - to be added.
        vessel - for which the step should be added.
      • getTradeMission

        public ITradeMissionData getTradeMission​(INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Retrieve the trade mission of a given vessel.
        Specified by:
        getTradeMission in interface IAIPlayer
        Parameters:
        vessel - for which to get the mission data
        Returns:
        trade mission for a specific vessel
      • setTradeMission

        public void setTradeMission​(INavigableVessel vessel,
                                    ITradeMissionData tradeMission)
        Description copied from interface: IAIPlayer
        Add trade mission data fo a vessel. If the data is null an existing entry will be removed.
        Specified by:
        setTradeMission in interface IAIPlayer
        Parameters:
        vessel - for which to set the trade mission data
        tradeMission - trade mission meta data
      • waitingForTradeStepToFinish

        public boolean waitingForTradeStepToFinish​(INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Check if the next trade step can be executed for the vessel, or if the last trade step requires waiting on an event.
        Specified by:
        waitingForTradeStepToFinish in interface IAIPlayer
        Parameters:
        vessel - for which the status should be checked.
        Returns:
        true if the next trade step is initiated upon an event.
      • updateTradeWaitingStatus

        public void updateTradeWaitingStatus​(INavigableVessel vessel,
                                             boolean wait)
        Description copied from interface: IAIPlayer
        Update the waiting status upon the execution of a trade step.
        Specified by:
        updateTradeWaitingStatus in interface IAIPlayer
        Parameters:
        vessel - for which the status should be updated.
        wait - inicate if the next trade step should wait.
      • isInitialized

        public boolean isInitialized​(INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Check if the trade strategy for the vessel is initialized.
        Specified by:
        isInitialized in interface IAIPlayer
        Parameters:
        vessel - to be checked
        Returns:
        true if the trade steps for the vessel are initialized.
      • getTradeSteps

        public java.util.List<ITradeStep> getTradeSteps​(INavigableVessel vessel)
        Description copied from interface: IAIPlayer
        Retrieve a copy of the trade steps of the vessel.
        Specified by:
        getTradeSteps in interface IAIPlayer
        Parameters:
        vessel - for which the next trade step should be checked.
        Returns:
        all trade steps for that vessel