Beispiel #1
0
 //TODO: Tests!  Specifically testing when
 // 1. an update has a negative vs positive value,
 // 2. and are all senses updated
 virtual public void UpdateFrom(SensoryDisplay other)
 {
     Visual.UpdateFrom(other.Visual);
     Auditory.UpdateFrom(other.Auditory);
     Smell.UpdateFrom(other.Smell);
     Taste.UpdateFrom(other.Taste);
 }
Beispiel #2
0
    private void  initStates()
    {
        takeState = Take.Start;
        activateState = Activate.Start;
        deactivateState = Deactivate.Start;
        releaseState = Release.Start;
        tasteState = Taste.Start;
        smellState = Smell.Start;

        /*openDoorState = OpenDoor.Start;
        closeDoorState = CloseDoor.Start;*/
        moveState = Move.Start;
        rotateState = Rotate.Start;
        turnState = Turn.Start;
        commandStatus = CommandStatus.Running;
        headFocusState = HeadFocus.Start;
        headResetState = HeadReset.Start;
        lookForState = LookFor.Start;

        speakState = Speak.Start;

        cancelState = Cancel.Start;
        getSensesState = GetSenses.Start;

        reset = true;           
    }
Beispiel #3
0
        private void ColorCell(Smell smell)
        {
            if (!smell.IsCellBased())
            {
                return;
            }

            try
            {
                var cell = (smell.SourceType == RiskSourceType.SiblingClass) ? ((SiblingClass)smell.Source).Cells[0] : (Cell)smell.Source;

                var excelCell = addIn.Application.Sheets[cell.Worksheet.Name].Cells[cell.Location.Row + 1, cell.Location.Column + 1];

                var smellyCell = new HighlightedCell(excelCell, excelCell.Interior.Pattern, excelCell.Interior.Color, excelCell.Comment);
                smellyCell.Apply(smell);
                if (!smellyCells.Any(x => x.Equals(smellyCell)))
                {
                    smellyCells.Add(smellyCell);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
        /// <remarks>
        /// Method <c>ToString</c> generates view of pizza table.
        /// Method takes parameter <c>yournick</c> type of string which is current Name of player
        /// </remarks>
        /// <param Name="yourNick"></param>
        /// <returns>
        ///     The returned value is string representation of Pizza view.
        /// </returns>
        public string ToString(string yourNick)
        {
            StringBuilder builder = new StringBuilder();

            int entireLength = 30;

            builder.Append(new string('-', entireLength)).Append("\n");

            int spaceLength = entireLength - "|".Length - "|".Length - yourNick.Length;

            int leftSpaceLength;
            int rightSpaceLength;

            if (spaceLength % 2 == 0)
            {
                int result = spaceLength / 2;
                leftSpaceLength  = result;
                rightSpaceLength = result;
            }
            else
            {
                int result = (spaceLength - 1) / 2;
                leftSpaceLength  = result;
                rightSpaceLength = result + 1;
            }

            builder.Append("|")
            .Append(new string(' ', leftSpaceLength))
            .Append(yourNick)
            .Append(new string(' ', rightSpaceLength))
            .Append("|").Append("\n");

            builder.Append(new string('-', entireLength)).Append("\n");

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Pizza", Name.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Hunger", Hunger.ToString(), builder);
            ProcessFieldsToTable(entireLength, "Sharpness", Sharpness.ToString(), builder);
            ProcessFieldsToTable(entireLength, "Flavor", Flavor.ToString(), builder);
            ProcessFieldsToTable(entireLength, "Smell", Smell.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Shape", Shape.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Score", Score.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");
            builder.Append(new string('-', entireLength)).Append("\n");

            return(builder.ToString());
        }
Beispiel #5
0
        public object Clone()
        {
            SensoryFeature visual   = (SensoryFeature)Visual.Clone();
            SensoryFeature auditory = (SensoryFeature)Auditory.Clone();
            SensoryFeature smell    = (SensoryFeature)Smell.Clone();
            SensoryFeature taste    = (SensoryFeature)Taste.Clone();

            return(new SensoryDisplay(visual, auditory, smell, taste));
        }
Beispiel #6
0
    // Need to propagate each smell from its source (potentially ignoring some terain types)
    // to determine how the smell fills the board. This is expensive but (mostly) only done
    // once at the beginning of the game.
    private void propagateSmells()
    {
        // Setup the smell-gird (A 2x2 array of Smell objects)
        this.smellArray = new Smell[GameManager.SIZE, GameManager.SIZE];

        // Begin by propagating the trees
        // Loop over all tiles and determine the smell from each tree at that tile
        // This is the "easy" one since birds will smell trees and don't need to worry
        // about the smell being blocked by high-elevation or water.
        for (int x = 0; x < GameManager.SIZE; x++)
        {
            for (int y = 0; y < GameManager.SIZE; y++)
            {
                // Loop over each tree and add the smell from that tree to the Smell object
                // at the current tile
                Smell curLocSmell = new Smell();
                foreach (Vector2 loc in treeLocations)
                {
                    float  deltaX   = Mathf.Abs(loc.x - x);
                    float  deltaY   = Mathf.Abs(loc.y - y);
                    double distance = Mathf.Sqrt(deltaX * deltaX + deltaY * deltaY);

                    if (distance < 0.1)
                    {
                        curLocSmell.addToSmell(SmellType.TreeFood, 1);
                    }
                    else
                    {
                        curLocSmell.addToSmell(SmellType.TreeFood, 1.0 / (distance * distance));
                    }
                }
                smellArray[x, y] = curLocSmell;
            }
        }

        // Now for bushes, the smell must "stop" at high-elevation and water tiles
        // this means we have to acutally propagate the smell through the environment
        // this can be costly but is necessary for good behavior from the agents.
        List <TileType> impassable = new List <TileType> {
            TileType.High, TileType.Water
        };

        foreach (Vector2 bushLoc in this.bushLocations)
        {
            propagateSmellFromRoot(bushLoc, SmellType.GroundFood, impassable);
        }

        // For wat the smell should stop when passing through mountains but not on other
        // water tiles
        impassable = new List <TileType> {
            TileType.High
        };
        foreach (Vector2 waterLoc in this.waterLocations)
        {
            propagateSmellFromRoot(waterLoc, SmellType.Water, impassable);
        }
    }
Beispiel #7
0
 private void end()
 {
     switch (action)
     {
         case Action.Take:
             takeState = Take.End;
             break;
         case Action.Activate:
             activateState = Activate.End;
             break;
         case Action.Deactivate:
             deactivateState = Deactivate.End;
             break;
         case Action.Release:
             releaseState = Release.End;
             break;
         case Action.Taste:
             tasteState = Taste.End;
             break;
         case Action.Smell:
             smellState = Smell.End;
             break;
         case Action.Move:
             moveState = Move.End;
             break;                
         case Action.Rotate:
             rotateState = Rotate.End;
             break;
         case Action.Turn:
               turnState = Turn.End;
               break;
         case Action.HeadFocus:
             headFocusState = HeadFocus.End;
             break;
         case Action.HeadReset:
             headResetState = HeadReset.End;
             break;
         case Action.LookFor:
             lookForState = LookFor.End;
             break;
         case Action.Speak:
             speakState = Speak.End;
             break;
         case Action.Cancel:
             cancelState = Cancel.End;
             break;
         case Action.GetSenses:
             getSensesState = GetSenses.End;
             break;
         default:
             break; ;
     }   
 }
Beispiel #8
0
        public void Apply(Smell smell)
        {
            Cell.Interior.Pattern = ExcelRaw.XlPattern.xlPatternSolid;
            Cell.Interior.Color   = ColorTranslator.ToOle(Color.Red);

            var existingComment   = "";
            var analyzerExtension = new tmpAnalyzerExtension(smell.AnalysisType);
            var comments          = analyzerExtension.GetSmellMessage(smell);

            if (!string.IsNullOrEmpty(comments))
            {
                if (Cell.Comment != null)
                {
                    existingComment = Cell.Comment.Text() + "\n";
                    Cell.Comment.Delete();
                }
                Cell.AddComment(existingComment + comments);
                Cell.Comment.Visible = true;
            }
        }
 public FoodDisappearsTrans(GameObject inv)
 {
     invocant           = inv;
     changeCreationTime = true;
     smell = GameObject.Find("Sushi").GetComponent <Smell>();
 }
Beispiel #10
0
 private void changeStatus(int value)
 {
     if (commandStatus != CommandStatus.Fail && commandStatus != CommandStatus.Success)
     {
         switch (action)
         {
             case Action.Take:
                 if (takeState != Take.End)
                     takeState+=value;
                 break;
             case Action.Activate:
                 if (activateState != Activate.End)
                     activateState += value;
                 break;
             case Action.Deactivate:
                 if (deactivateState != Deactivate.End)
                     deactivateState += value;
                 break;
             case Action.Release:
                 if (releaseState != Release.End)
                     releaseState += value;
                 break;
             case Action.Taste:
                 if (tasteState != Taste.End)
                     tasteState += value;
                 break;
             case Action.Smell:
                 if (smellState != Smell.End)
                     smellState += value;
                 break;
             case Action.Move:
                 if (moveState != Move.End)
                     moveState+=value;
                 break;
             case Action.Rotate:
                  if (rotateState != Rotate.End)
                     rotateState+=value;
                 break;
             case Action.Turn:
                 if (turnState != Turn.End)
                      turnState+=value;
                break;
             case Action.HeadFocus:
                 if (headFocusState != HeadFocus.End)
                     headFocusState+=value;
                 break;
             case Action.HeadReset:
                 if (headResetState != HeadReset.End)
                     headResetState+=value;
                 break;
             case Action.LookFor:
                 if (lookForState != LookFor.End)
                     lookForState += value;
                 break;
             case Action.Speak:
                 if (speakState != Speak.End)
                    speakState += value;
                 break;
             case Action.Cancel:
                 if (cancelState != Cancel.End)
                     cancelState += value;
                 break;
             case Action.GetSenses:
                 if (getSensesState != GetSenses.End)
                     getSensesState += value;
                 break;
             default:
                 break;
         }
         commandStatus = CommandStatus.Running;
     }
 }
Beispiel #11
0
 public SmellAttribute(Smell type, String reason, double effort)
 {
 }