예제 #1
0
    public override AIState ApplyAction(AIState currentState)
    {
        AIState cloneState = base.ApplyAction(currentState);

        cloneState.CurrentPlayerState.PickUp(id);

        bool hasCleared = false;

        foreach (int tableID in cloneState.TableStateIndexList)
        {
            TableSpace tState = cloneState.ItemStateList[tableID] as TableSpace;
            if (tState.ItemIDOnTable == id)
            {
                tState.ItemIDOnTable = Item.NOTHING_ID;
                hasCleared           = true;
                break;
            }
        }

        if (!hasCleared)
        {
            foreach (int boardID in cloneState.BoardStateIndexList)
            {
                BoardState bState = cloneState.ItemStateList[boardID] as BoardState;
                if (bState.HoldingItemID == id)
                {
                    bState.HoldingItemID = Item.NOTHING_ID;
                    break;
                }
            }
        }


        return(cloneState);
    }
예제 #2
0
        public override string ToArgs()
        {
            List <string> options = new List <string>
            {
                Url.Formatted(),
                          Driver.Formatted(),
                          User.Formatted(),
                          Password.Formatted(),
                          ConnectRetries.Formatted(),
                          InitSql.Formatted(),
                          DefaultSchema.Formatted(),
                          Schemas.Formatted(),
                          Color.Formatted(),
                          Table.Formatted(),
                          TableSpace.Formatted(),
                          JarDirs.Formatted(),
                          Callbacks.Formatted(),
                          SkipDefaultCallbacks.Formatted(),
                          BaselineVersion.Formatted(),
                          BaselineDescription.Formatted(),
                          ValidateMigrationNaming.Formatted(),
                          WorkingDirectory.Formatted(),
                          LicenseKey.Formatted()
            };

            return(ToArgs(options));
        }
예제 #3
0
        public override string ToArgs()
        {
            List <string> options = new List <string>
            {
                Url.Formatted(),
                          Driver.Formatted(),
                          User.Formatted(),
                          Password.Formatted(),
                          ConnectRetries.Formatted(),
                          InitSql.Formatted(),
                          Schemas.Formatted(),
                          Table.Formatted(),
                          Locations.Formatted(),
                          JarDirs.Formatted(),
                          SqlMigrationPrefix.Formatted(),
                          UndoSqlMigrationPrefix.Formatted(),
                          RepeatableSqlMigrationPrefix.Formatted(),
                          SqlMigrationSeparator.Formatted(),
                          SqlMigrationSuffixes.Formatted(),
                          Stream.Formatted(),
                          Batch.Formatted(),
                          Mixed.Formatted(),
                          Group.Formatted(),
                          Encoding.Formatted(),
                          PlaceholderReplacement.Formatted(),
                          Placeholders.Formatted(),
                          PlaceholderPrefix.Formatted(),
                          PlaceholderSuffix.Formatted(),
                          Resolvers.Formatted(),
                          SkipDefaultResolvers.Formatted(),
                          Callbacks.Formatted(),
                          SkipDefaultCallbacks.Formatted(),
                          Target.Formatted(),
                          OutOfOrder.Formatted(),
                          ValidateOnMigrate.Formatted(),
                          CleanOnValidationError.Formatted(),
                          IgnoreMissingMigrations.Formatted(),
                          IgnoreIgnoredMigrations.Formatted(),
                          IgnoreFutureMigrations.Formatted(),
                          CleanDisabled.Formatted(),
                          BaselineOnMigrate.Formatted(),
                          BaselineVersion.Formatted(),
                          BaselineDescription.Formatted(),
                          InstalledBy.Formatted(),
                          ErrorOverrides.Formatted(),
                          DryRunOutput.Formatted(),
                          OracleSqlplus.Formatted(),
                          LicenseKey.Formatted(),
                          DefaultSchema.Formatted(),
                          TableSpace.Formatted(),
                          Color.Formatted(),
                          ValidateMigrationNaming.Formatted(),
                          OutputQueryResults.Formatted(),
                          OracleSqlplusWarn.Formatted(),
                          WorkingDirectory.Formatted()
            };

            return(ToArgs(options));
        }
예제 #4
0
    public override void LoadState(ItemState state)
    {
        TableSpace tState = state as TableSpace;

        if (!tState.IsFree())
        {
            HeldItem = GetItemManager().ItemList[tState.ItemIDOnTable];
            if (HeldItem != null)
            {
                HeldItem.transform.position = HoldingPosition.position;
            }
        }
    }
예제 #5
0
        public string ToDDL(Table parent)
        {
            var builder = new StringBuilder();

            builder.Append("CREATE ");

            if (IsUnique)
            {
                builder.Append("UNIQUE ");
            }
            builder.Append("INDEX ");

            if (IsConcurrent)
            {
                builder.Append("CONCURRENTLY ");
            }

            builder.Append(Name);



            builder.Append(" ON ");
            builder.Append(parent.Identifier);
            builder.Append(" USING ");
            builder.Append(Method);
            builder.Append(" ");
            builder.Append(correctedExpression());

            if (TableSpace.IsNotEmpty())
            {
                builder.Append(" TABLESPACE ");
                builder.Append(TableSpace);
            }

            if (Predicate.IsNotEmpty())
            {
                builder.Append(" WHERE ");
                builder.Append($"({Predicate})");
            }

            if (FillFactor.HasValue)
            {
                builder.Append($" WITH (fillfactor='{FillFactor}')");
            }

            builder.Append(";");


            return(builder.ToString());
        }
예제 #6
0
    public override bool Equals(object obj)
    {
        TableSpace otherState = obj as TableSpace;

        if (otherState == null)
        {
            return(false);
        }

        if (this == otherState)
        {
            return(true);
        }

        // Items are always assumed to be sorted.
        return(ItemIDOnTable == otherState.ItemIDOnTable);
    }
예제 #7
0
    public override AIState ApplyAction(AIState currentState)
    {
        AIState cloneState = base.ApplyAction(currentState);

        int droppedItemID = cloneState.CurrentPlayerState.Drop();

        if (cloneState.ItemStateList[id].MyItemType == ItemType.TABLE)
        {
            TableSpace table = cloneState.ItemStateList[id] as TableSpace;
            table.ItemIDOnTable = droppedItemID;
        }
        if (cloneState.ItemStateList[id].MyItemType == ItemType.BOARD)
        {
            BoardState board = cloneState.ItemStateList[id] as BoardState;
            board.HoldingItemID = droppedItemID;
        }
        if (cloneState.ItemStateList[id].MyItemType == ItemType.POT)
        {
            PotState  pot  = cloneState.ItemStateList[id] as PotState;
            MealState meal = cloneState.ItemStateList[pot.mealID] as MealState;

            (cloneState.ItemStateList[droppedItemID] as IngredientState).IsInMeal = true;

            meal.ContainedIngredientIDs.Add(droppedItemID);
            meal.cookDuration = Mathf.Min(meal.cookDuration, (meal.ContainedIngredientIDs.Count - 1) * MealState.COOK_TIME_PER_INGREDIENT);
        }
        if (cloneState.ItemStateList[id].MyItemType == ItemType.PLATE)
        {
            PlateState plate = cloneState.ItemStateList[id] as PlateState;
            MealState  meal  = cloneState.ItemStateList[plate.mealID] as MealState;

            (cloneState.ItemStateList[droppedItemID] as IngredientState).IsInMeal = true;
            meal.ContainedIngredientIDs.Add(droppedItemID);
            meal.cookDuration = Mathf.Min(meal.cookDuration, (meal.ContainedIngredientIDs.Count - 1) * MealState.COOK_TIME_PER_INGREDIENT);
        }
        return(cloneState);
    }
예제 #8
0
    public override bool isValid(AIState currentState)
    {
        if (currentState.CurrentPlayerState.HandsFree())
        {
            return(false);
        }
        else
        {
            int droppedItemID = currentState.CurrentPlayerState.HoldingItemID;

            if (currentState.ItemStateList[droppedItemID].MyItemType == ItemType.MEAL ||
                currentState.ItemStateList[droppedItemID].MyItemType == ItemType.TABLE ||
                currentState.ItemStateList[droppedItemID].MyItemType == ItemType.BOARD)
            {
                return(false);
            }


            if (currentState.ItemStateList[id].MyItemType == ItemType.TABLE)
            {
                TableSpace table = currentState.ItemStateList[id] as TableSpace;
                return(table.IsFree());
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.BOARD)
            {
                BoardState board = currentState.ItemStateList[id] as BoardState;
                return((currentState.ItemStateList[droppedItemID].MyItemType == ItemType.INGREDIENT) &&
                       board.IsFree());
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.POT)
            {
                if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT)
                {
                    return(false);
                }
                else
                {
                    if ((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared &&
                        (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned)
                    {
                        PotState  pot  = currentState.ItemStateList[id] as PotState;
                        MealState meal = currentState.ItemStateList[pot.mealID] as MealState;
                        return(meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt());
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (currentState.ItemStateList[id].MyItemType == ItemType.PLATE)
            {
                if (currentState.ItemStateList[droppedItemID].MyItemType != ItemType.INGREDIENT)
                {
                    return(false);
                }
                else
                {
                    PlateState plate = currentState.ItemStateList[id] as PlateState;
                    MealState  meal  = currentState.ItemStateList[plate.mealID] as MealState;
                    return((currentState.ItemStateList[droppedItemID] as IngredientState).IsPrepared &&
                           (currentState.ItemStateList[droppedItemID] as IngredientState).IsSpawned &&
                           !plate.IsSubmitted &&
                           !meal.IsBurnt());
                }
            }
            else
            {
                return(false);
            }
        }
    }
예제 #9
0
    /// <summary>
    /// Used to get all of the valid actions for the current state
    /// </summary>
    /// <returns></returns>
    public List <Action> GetValidActions(AIState state)
    {
        List <Action> validActions = new List <Action>();

        //Waiting around
        validActions.Add(new IdleAction());

        //Things you can do when your hands are free
        if (state.CurrentPlayerState.HandsFree())
        {
            //Spawning items
            foreach (IngredientType type in System.Enum.GetValues(typeof(IngredientType)))
            {
                SpawnAction spawnAction = new SpawnAction(type);
                if (spawnAction.isValid(state))
                {
                    validActions.Add(spawnAction);
                }
            }

            PickUpAction pickupAction;
            //Picking up everything
            //Ingredients
            foreach (int ingredientID in state.IngredientStateIndexList)
            {
                IngredientState ingredient = state.ItemStateList[ingredientID] as IngredientState;
                if (ingredient.IsSpawned && !ingredient.IsInMeal)
                {
                    pickupAction = new PickUpAction(ingredient.ID);
                    validActions.Add(pickupAction);
                }
            }

            //Pots
            foreach (int potID in state.PotStateIndexList)
            {
                PotState pot = state.ItemStateList[potID] as PotState;
                pickupAction = new PickUpAction(pot.ID);
                validActions.Add(pickupAction);
            }

            //Plates
            foreach (int plateID in state.PlateStateIndexList)
            {
                PlateState plate = state.ItemStateList[plateID] as PlateState;
                pickupAction = new PickUpAction(plate.ID);
                validActions.Add(pickupAction);
            }

            PrepareAction prepAction;
            foreach (int boardID in state.BoardStateIndexList)
            {
                BoardState bState = state.ItemStateList[boardID] as BoardState;
                if (!bState.IsFree())
                {
                    IngredientState iState = state.ItemStateList[bState.HoldingItemID] as IngredientState;
                    if (iState != null && !iState.IsPrepared)
                    {
                        prepAction = new PrepareAction(boardID);
                        validActions.Add(prepAction);
                    }
                }
            }
        }

        //Things you can do when you have something in hand
        else
        {
            DropOffAction  dropoffAction;
            TransferAction transferAction;
            ItemState      itemState = state.ItemStateList[state.CurrentPlayerState.HoldingItemID];
            ItemType       type      = itemState.MyItemType;

            if (type == ItemType.INGREDIENT)
            {
                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving ingredients to a cutting board
                foreach (int boardID in state.BoardStateIndexList)
                {
                    BoardState board = state.ItemStateList[boardID] as BoardState;
                    if (board.IsFree())
                    {
                        dropoffAction = new DropOffAction(board.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                if ((itemState as IngredientState).IsPrepared)
                {
                    //Moving ingredients to a pot
                    foreach (int potID in state.PotStateIndexList)
                    {
                        PotState  pot  = state.ItemStateList[potID] as PotState;
                        MealState meal = state.ItemStateList[pot.mealID] as MealState;
                        if (meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(pot.ID);
                            validActions.Add(dropoffAction);
                        }
                    }

                    //Moving ingredients to a plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        PlateState plate = state.ItemStateList[plateID] as PlateState;
                        MealState  meal  = state.ItemStateList[plate.mealID] as MealState;
                        if (!plate.IsSubmitted && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(plate.ID);
                            validActions.Add(dropoffAction);
                        }
                    }
                }
            }

            if (type == ItemType.POT)
            {
                PotState  pot  = itemState as PotState;
                MealState meal = state.ItemStateList[pot.mealID] as MealState;

                //Putting the pot on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving meal to a pot
                transferAction = new TransferAction(Item.NOTHING_ID);
                foreach (int potID in state.PotStateIndexList)
                {
                    transferAction.id = potID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }

                //Moving the meal to another plate
                foreach (int plateID in state.PlateStateIndexList)
                {
                    transferAction.id = plateID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }
            }

            if (type == ItemType.PLATE)
            {
                PlateState plate = itemState as PlateState;

                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //If the plate is non-empty
                MealState heldMeal = state.ItemStateList[plate.mealID] as MealState;
                if (heldMeal.IsSpawned())
                {
                    //Submitting the meal
                    if (heldMeal.IsCooked())
                    {
                        SubmitOrderAction submitAction = new SubmitOrderAction();
                        validActions.Add(submitAction);
                    }

                    //Moving meal to a pot
                    transferAction = new TransferAction(Item.NOTHING_ID);
                    foreach (int potID in state.PotStateIndexList)
                    {
                        transferAction.id = potID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }

                    //Moving the meal to another plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        transferAction.id = plateID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }
                }
            }
        }


        return(validActions);
    }