Example #1
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            if (RndGen.Next(9) > 0)
            {
                SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

                PointF location = Positions.Center();

                if (LearningTaskHelpers.FlipCoin(RndGen))
                {
                    WrappedWorld.CreateRandomFood(location, size, RndGen);
                    Actions.Eat = true;
                }
                else
                {
                    WrappedWorld.CreateRandomStone(location, size, RndGen);
                }

                if (LearningTaskHelpers.FlipCoin(RndGen))
                {
                    PointF location2 = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);
                    WrappedWorld.CreateRandomStone(location2, size, RndGen);
                }
            }

            WriteActions();
        }
Example #2
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            int    positionsCount    = Positions.Positions.Count;
            int    randomLocationIdx = RndGen.Next(positionsCount);
            PointF location          = Positions.Positions[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsCount - 1) + randomLocationIdx + 1) % positionsCount;
            PointF location2          = Positions.Positions[randomLocationIdx2];

            Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location, size, RndGen);

            Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.Center()));

            if (LearningTaskHelpers.FlipCoin(RndGen))
            {
                WrappedWorld.CreateRandomFood(location2, size, RndGen);
            }
            else
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #3
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(true, false, false, false);

            int randomLocationIdx = RndGen.Next(ScConstants.numPositions);

            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                AddShape(randomLocationIdx);
                Actions.Shapes[ShapeIndex] = true;
            }


            int nextRandomLocationIdx = RndGen.Next(randomLocationIdx + 1, randomLocationIdx + ScConstants.numPositions);

            nextRandomLocationIdx %= ScConstants.numPositions;

            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                AddShape(nextRandomLocationIdx);
                Actions.Shapes[ShapeIndex] = true;
            }

            WriteActions();
        }
Example #4
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            int       positionsCount    = Positions.Positions.Count;
            const int randomLocationIdx = 4;
            PointF    location          = Positions.Positions[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsCount - 1) + randomLocationIdx + 1) % positionsCount;
            PointF location2          = Positions.Positions[randomLocationIdx2];

            WrappedWorld.CreateRandomVeryGoodFood(location, size, RndGen);
            Actions.Eat = true;

            if (RndGen.Next(3) > 0)
            {
                Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location2, size, RndGen);
                Actions.Eat      = false;
                Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.GetCenter()));
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomFood(location2, size, RndGen);
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #5
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            PointF location = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);

            Shape randomVeryGoodFood = WrappedWorld.CreateRandomVeryGoodFood(location, size, RndGen);

            Actions.Movement = MoveActionsToTarget(randomVeryGoodFood.Center());

            PointF location2 = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);

            if (RndGen.Next(3) > 0)
            {
                Shape randomEnemy = WrappedWorld.CreateRandomEnemy(location2, size, RndGen);
                Actions.Movement = NegateMoveActions(MoveActionsToTarget(randomEnemy.Center()));
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomFood(location2, size, RndGen);
            }
            else if (RndGen.Next(3) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #6
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, false, true, true);

            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            int    positionsWcCount  = Positions.PositionsWithoutCenter.Count;
            int    randomLocationIdx = RndGen.Next(positionsWcCount);
            PointF location          = Positions.PositionsWithoutCenter[randomLocationIdx];

            int    randomLocationIdx2 = (RndGen.Next(positionsWcCount - 1) + randomLocationIdx + 1) % positionsWcCount;
            PointF location2          = Positions.PositionsWithoutCenter[randomLocationIdx2];

            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                Shape randomFood = WrappedWorld.CreateRandomFood(location, size, RndGen);
                Actions.Movement = MoveActionsToTarget(randomFood.GetCenter());
            }
            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                WrappedWorld.CreateRandomStone(location2, size, RndGen);
            }

            WriteActions();
        }
Example #7
0
 public Asteroid(AsteroidSize size)
     : base(new Point(0, 0))
 {
     _size             = size;
     CurrentLocation.X = RndGen.Next(2) * 9999;
     CurrentLocation.Y = RndGen.Next(7499);
     RandomVelocity();
     InitPoints();
 }
Example #8
0
        public Challenge(int range, bool withDiv)
        {
            switch (RndGen.Next(0, withDiv ? 4 : 3))
            {
            case 0:
                Operator = OpSum;
                Result   = RndGen.Next(range / 5, range + 1);
                Left     = RndGen.Next(range / 10, Result);
                Right    = Result - Left;
                break;

            case 1:
                Operator = OpSub;
                Left     = RndGen.Next(range / 5, range + 1);
                Right    = RndGen.Next(1, Left);
                Result   = Left - Right;
                break;

            case 2:
                Operator = OpMul;
                Result   = RndGen.Next((int)Math.Sqrt(range), range + 1);
                Left     = RndGen.Next(2, (Result / 3) + 1);
                Right    = Result / Left;
                Result   = Left * Right;    // Due to rounding, the initial result may not match.
                break;

            case 3:
                Operator = OpDiv;
                Left     = RndGen.Next((int)Math.Sqrt(range), range + 1);
                Result   = RndGen.Next(2, (Left / 3) + 1);
                Right    = Left / Result;
                Left     = Result * Right;  // Due to rounding, the initial left op. may not match.
                break;
            }
            switch (RndGen.Next(0, 3))
            {
            case 0:
                ShowLeft   = false;
                ShowRight  = true;
                ShowResult = true;
                break;

            case 1:
                ShowLeft   = true;
                ShowRight  = false;
                ShowResult = true;
                break;

            case 2:
                ShowLeft   = true;
                ShowRight  = true;
                ShowResult = false;
                break;
            }
        }
Example #9
0
        public override void Generate()
        {
            BaseAim = BaseEnergy = BaseSpeed = BaseStrength = BaseVigor = 2;
            #region Add variance to stats
            if (RndGen.Next(0, 100) < 10)
            {
                BaseAim--;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseAim++;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseEnergy--;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseEnergy++;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseSpeed--;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseSpeed++;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseStrength--;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseStrength++;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseVigor--;
            }
            if (RndGen.Next(0, 100) < 10)
            {
                BaseVigor++;
            }
            #endregion

            Level            = (World.Map)Utilities.InterStateResources.Instance.Resources["Game_CurrentLevel"];
            InventoryHandler = new Guardian_Roguelike.World.Items.Inventory();

            //TODO: Find out if you can use Dwarf Fortress' language files to generate names
            //Until then, "Gear Inkmoist" it is! :P
            FirstName = "Olon";
            LastName  = "Likotidash";
        }
Example #10
0
 public Explosion(Point ptExplosion, double timeFactor)
     : base(ptExplosion)
 {
     _lifeLeft       = (int)(ExplosionLife * timeFactor);
     _points         = new Point[NumExpPoints];
     _pointsVelocity = new Point[NumExpPoints];
     for (var i = 0; i < NumExpPoints; i++)
     {
         _points[i]         = ptExplosion;
         _pointsVelocity[i] = new Point((int)((double)(RndGen.Next(1200) - 600) / 60), (int)((double)(RndGen.Next(1200) - 600) / 60));
     }
 }
Example #11
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(false, true, false, false);

            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                AddShape();
                Actions.Colors[ColorIndex] = true;
            }

            WriteActions();
        }
Example #12
0
        protected void AddShape()
        {
            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            Color color = Colors.GetRandomColor(RndGen);

            PointF location = WrappedWorld.RandomPositionInsidePowNonCovering(RndGen, size);

            ShapeIndex = RndGen.Next(ScConstants.numShapes);
            Shape.Shapes randomShape = (Shape.Shapes)ShapeIndex;

            WrappedWorld.CreateShape(randomShape, color, location, size);
        }
Example #13
0
        protected override void CreateScene()
        {
            Actions = new AvatarsActions(true, false, false, false);

            if (RndGen.Next(ScConstants.numShapes + 1) > 0)
            {
                const int fixedLocationIndex = 4;
                AddShape(fixedLocationIndex);

                Actions.Shapes[ShapeIndex] = true;
            }

            WriteActions();
        }
Example #14
0
        public FSM_Aggressive(CreatureBase C)
            : base(C)
        {
            CurState           = AIState.Wander;
            CurWanderDirection = new Point();
            do
            {
                CurWanderDirection.X = RndGen.Next(-1, 1);
                CurWanderDirection.Y = RndGen.Next(-1, 1);
            } while (CurWanderDirection.X == 0 && CurWanderDirection.Y == 0);

            PlayerLastSeenAt = new Point();

            Player = (CreatureBase)Utilities.InterStateResources.Instance.Resources["Game_PlayerCreature"];
        }
Example #15
0
        protected override void AddShape(int randomLocationIndex)
        {
            SizeF size = new SizeF(WrappedWorld.GetPowGeometry().Width / 4, WrappedWorld.GetPowGeometry().Height / 4);

            Color color = Colors.GetRandomColor(RndGen, out ColorIndex);

            PointF location = Positions.Positions[randomLocationIndex];

            ShapeIndex = RndGen.Next(ScConstants.numShapes);
            Shape.Shapes randomShape = (Shape.Shapes)ShapeIndex;

            WrappedWorld.CreateShape(randomShape, color, location, size);

            GenerationsCheckTable[randomLocationIndex][ColorIndex] = true;
        }
Example #16
0
        static void Main(string[] args)
        {
            Console.WriteLine(About.ToString());
            EpidLib.Virus v = new EpidLib.Virus();
            Console.WriteLine(v.ToString());
            RndGen rndGen = new RndGen();

            rndGen.Reset();
            Console.WriteLine(rndGen.ToString());
            for (int i = 0; i < 250; i++)
            {
                Console.WriteLine(rndGen.NextNorm());
            }

            rndGen.ToCSV(0, 1, 1500);

            Attribute attr = new Attribute();

            Console.WriteLine(attr);

            FreqTable ft = new FreqTable();

            ft.Append("male", 0.48);
            ft.Append("female", 0.52);

            Console.WriteLine(ft);

            ft.Cumulative = true;
            Console.WriteLine(ft);
            ft.Cumulative = false;
            Console.WriteLine(ft);

            FromTo diap1 = new FromTo()
            {
                From = 0, To = 1
            };

            Console.WriteLine(diap1);

            FromToPercent diap2 = new FromToPercent()
            {
                FromPercent = 0.2, ToPercent = 0.3
            };

            Console.WriteLine(diap2);
        }
Example #17
0
        public override void Draw(ScreenCanvas sc, int x, int y)
        {
            if (_state != ShipState.Alive)
            {
                return;
            }

            if (_thrustOn)
            {
                var a    = PointsTransformed[PointThrust1];
                var b    = PointsTransformed[PointThrust2];
                var num  = RndGen.Next(200) + 100;
                var list = new List <Point>(3)
                {
                    a,
                    b,
                    new Point((a.X + b.X) / 2 + (int)(num * Math.Sin(Radians)), (a.Y + b.Y) / 2 + (int)(-num * Math.Cos(Radians)))
                };

                DrawPolyToScreen(list, sc, x, y, GetRandomFireColor());
            }

            base.Draw(sc, x, y);
        }
Example #18
0
 private void RandomVelocity()
 {
     _rotateSpeed = (float)(RndGen.Next(10000) - 5000) / 60;
     VelocityX    = (float)((RndGen.NextDouble() * 2000 - 1000) * ((3 - (int)_size + 1) * 1.05) / 60);
     VelocityY    = (float)((RndGen.NextDouble() * 2000 - 1000) * ((3 - (int)_size + 1) * 1.05) / 60);
 }
Example #19
0
        public override void TakeTurn()
        {
            switch (CurState)
            {
            case (AIState.Wander):
                //If the current direction is walkable, do it!
                if (LinkedCreature.Level.CheckWalkable(Utilities.GeneralMethods.AddPoints(LinkedCreature.Position, CurWanderDirection)))
                {
                    LinkedCreature.Move(CurWanderDirection);
                    if (RndGen.Next(0, 100) < 25)     //Maybe decide on a new direction
                    {
                        do
                        {
                            CurWanderDirection.X = RndGen.Next(-1, 1);
                            CurWanderDirection.Y = RndGen.Next(-1, 1);
                        } while (CurWanderDirection.X == 0 && CurWanderDirection.Y == 0);
                    }
                }
                else     //Not walkable, decide on a new one.
                {
                    do
                    {
                        CurWanderDirection.X = RndGen.Next(-1, 1);
                        CurWanderDirection.Y = RndGen.Next(-1, 1);
                    } while (CurWanderDirection.X == 0 && CurWanderDirection.Y == 0);
                }

                FOVHandler.CalculateFOV(LinkedCreature.Position.X, LinkedCreature.Position.Y, 0, false, libtcodWrapper.FovAlgorithm.Basic);
                if (FOVHandler.CheckTileFOV(Player.Position.X, Player.Position.Y))               //If can see player
                {
                    PlayerLastSeenAt   = Player.Position;                                        //Remember where
                    CurState           = AIState.Follow;                                         //Follow him!
                    CurFollowPath      = ComputePath(LinkedCreature.Position, PlayerLastSeenAt); //How do we get there?
                    CurFollowPathIndex = 0;                                                      //Start from the beginning
                }
                if (LinkedCreature.Limbs[0].HP <= 33)                                            //OH NO!
                {
                    CurState = AIState.Flee;
                }
                break;

            case (AIState.Follow):
                FOVHandler.CalculateFOV(LinkedCreature.Position.X, LinkedCreature.Position.Y, 0, false, libtcodWrapper.FovAlgorithm.Basic);
                if (PlayerLastSeenAt != Player.Position)                                             //If player isn't in the same place still...
                {
                    if (FOVHandler.CheckTileFOV(Player.Position.X, Player.Position.Y))               //And we can see player
                    {
                        PlayerLastSeenAt   = Player.Position;                                        //Update our memory
                        CurFollowPath      = ComputePath(LinkedCreature.Position, PlayerLastSeenAt); //And figure out a new path.
                        CurFollowPathIndex = 0;                                                      //And start from the beginning of it!
                    }
                }
                if (CurFollowPathIndex >= 0 && CurFollowPathIndex < CurFollowPath.Count - 1)  //We're on the way to the player (Or where we saw him last)
                {
                    LinkedCreature.Move(CurFollowPath[CurFollowPathIndex].X - LinkedCreature.Position.X, CurFollowPath[CurFollowPathIndex].Y - LinkedCreature.Position.Y);
                }
                CurFollowPathIndex++;
                if (Utilities.GeneralMethods.Distance(LinkedCreature.Position, Player.Position) == 1)                                //We're in stabby range!
                {
                    CurState = AIState.Attack;                                                                                       //ATTACK!!!!
                }
                if (CurFollowPathIndex == CurFollowPath.Count - 1 && !FOVHandler.CheckTileFOV(Player.Position.X, Player.Position.Y)) //We're there but he's gone! We can't see him!
                {
                    CurState = AIState.Wander;
                }
                if (LinkedCreature.Limbs[0].HP <= 33)     //Ack! We've been wounded!
                {
                    CurState = AIState.Flee;
                }
                break;

            case (AIState.Attack):
                Utilities.MessageLog.AddMsg(LinkedCreature.FirstName + " swings at you!");
                LinkedCreature.Attack(Player);
                if (Utilities.GeneralMethods.Distance(LinkedCreature.Position, Player.Position) != 1)
                {
                    CurState = AIState.Follow;
                }
                if (LinkedCreature.Limbs[0].HP <= 33)
                {
                    CurState = AIState.Flee;
                }
                break;

            case (AIState.Flee):
                Point Diff    = Utilities.GeneralMethods.SubtractPoints(LinkedCreature.Position, Player.Position);
                Point FleeDir = new Point();
                if (Diff.X > 0)
                {
                    FleeDir.X = 1;
                }
                else if (Diff.X < 0)
                {
                    FleeDir.X = -1;
                }
                else
                {
                    FleeDir.X = 0;
                }
                if (Diff.Y > 0)
                {
                    FleeDir.Y = 1;
                }
                else if (Diff.Y < 0)
                {
                    FleeDir.Y = -1;
                }
                else
                {
                    FleeDir.Y = 0;
                }
                LinkedCreature.Move(FleeDir);
                break;
            }
        }
Example #20
0
 private int GetNextRestingWheelSlice()
 {
     //Converts slices in a string to a json then deserializes and then based on the probability of each it retruns an int.
     return(RndGen.probabilityBasedRnd(WheelJsonHelper.GetWheelSlicesFromString(tempWheel.AllWheelSlices)
                                       .Select <WheelSliceContainer, string>(x => x.probability.ToString()).ToArray()));
 }
Example #21
0
 public bool Hyperspace()
 {
     CurrentLocation.X = RndGen.Next(8000) + 1000;
     CurrentLocation.Y = RndGen.Next(6000) + 750;
     return(RndGen.Next(10) != 1);
 }