Exemple #1
0
        public void WriteToFile(LearnInputOutput inputOutputToLearn)
        {
            String output = inputOutputToLearn.Output[0].ToString();

            F.WriteByte((byte)output[0]);
            F.WriteByte(45);
            for (int i = 0; i < inputOutputToLearn.Input.Count() - 1; i++)
            {
                F.WriteByte((byte)(inputOutputToLearn.Input[i] + 48));
            }
            F.WriteByte(124);
            String result = inputOutputToLearn.Input[inputOutputToLearn.Input.Count() - 1].ToString();

            for (int i = 0; i < result.Length; i++)
            {
                F.WriteByte((byte)(result[i]));
            }


            F.WriteByte(13);
            F.WriteByte(10);
        }
Exemple #2
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     data    = new DataCollector();
     bot     = new Bot();
     win     = new Win();
     player1 = new Player(Size, 1, data);
     player2 = new Player(Size, 2, data);
     TexturePack.TexturePackLoad(this);
     fontPack      = new FontPack(this);
     userInterface = new UserInterface(player1, player2, fontPack, data);
     GameEventEngine.Add(new GameEventCyclic(() => {
         if (player1.IsInactive == true)
         {
             LearnInputOutput learning = new LearnInputOutput(player2.ListOfForces, player1.ListOfForces, player1.Upgrades, player1.Cash, 5);
             data.WriteToFile(learning);
         }
         else
         {
             player1.IsInactive = true;
         }
     }, 15, int.MaxValue));
     base.Initialize();
 }
Exemple #3
0
        public bool AddForces(Force force, Player opponent, GameTime gameTime)
        {
            if (PurchasePack.ForceCosts[(int)force.Id] > Cash)
            {
                return(false);
            }
            else
            {
                if (this.PlayerID == 1)
                {
                    LearnInputOutput learning = new LearnInputOutput(opponent.ListOfForces, this.ListOfForces, this.Upgrades, this.Cash, (int)force.Id);
                    Data.WriteToFile(learning);
                    this.DidSomething(gameTime);
                }
                Cash -= PurchasePack.ForceCosts[(int)force.Id];
                force.OriginalRange = force.Range;
                UpgradePack.UpgradeForce(force, Upgrades[(int)force.Id]);
                force.MaxHp = force.Hp;
                ListOfForces.Add(force);

                return(true);
            }
        }
        private void ProcessKeyboardInput(GameTime gameTime, Bot bot)
        {
            KeyboardState state = Keyboard.GetState();

            if (state.IsKeyDown(Keys.Right) & !PrevState.IsKeyDown(Keys.Right))
            {
                FocusID     += 1;
                UpgradeFocus = false;
            }
            if (state.IsKeyDown(Keys.Left) & !PrevState.IsKeyDown(Keys.Left))
            {
                FocusID     -= 1;
                UpgradeFocus = false;
            }
            if (state.IsKeyDown(Keys.Down) & !PrevState.IsKeyDown(Keys.Down))
            {
                UpgradeFocus = !UpgradeFocus;
            }
            if (state.IsKeyDown(Keys.Up) & !PrevState.IsKeyDown(Keys.Up))
            {
                UpgradeFocus = !UpgradeFocus;
            }

            if (FocusID < 0)
            {
                FocusID = NumberOfButtons - 1;
            }
            else if (FocusID >= NumberOfButtons)
            {
                FocusID = 0;
            }

            if (state.IsKeyDown(Keys.Enter) & !PrevState.IsKeyDown(Keys.Enter))
            {
                bot.IsStarted = true;
                if (!UpgradeFocus)
                {
                    switch ((ButtonID)FocusID)
                    {
                    case ButtonID.explosiveForceButton:
                    {
                        Player1.AddForces(new ExplosiveForce(gameTime), Player2, gameTime);
                        break;
                    }

                    case ButtonID.rifleForceButton:
                    {
                        Player1.AddForces(new RifleForce(gameTime), Player2, gameTime);
                        break;
                    }

                    case ButtonID.rocketForceButton:
                    {
                        Player1.AddForces(new RocketForce(gameTime), Player2, gameTime);
                        break;
                    }

                    case ButtonID.droneCarrierForceButton:
                    {
                        Player1.AddForces(new DroneCarrierForce(gameTime), Player2, gameTime);
                        break;
                    }

                    case ButtonID.cannonForceButton:
                    {
                        Player1.AddForces(new CannonForce(gameTime), Player2, gameTime);
                        break;
                    }

                    default:
                        break;
                    }
                }
                else
                {
                    LearnInputOutput learning = new LearnInputOutput(Player2.ListOfForces, Player1.ListOfForces, Player1.Upgrades, Player1.Cash, (int)((int)((ForcesType)FocusID) + 6));
                    Data.WriteToFile(learning);
                    Player1.DidSomething(gameTime);
                    Player1.Upgrade((ForcesType)FocusID);
                }
            }
            //TEMP ADDING ENEMY

            /*
             * if (state.IsKeyDown(Keys.NumPad1) & !PrevState.IsKeyDown(Keys.NumPad1))
             * {
             *  Player2.AddForces(new ExplosiveForce(gameTime), Player1, gameTime);
             * }
             * if (state.IsKeyDown(Keys.NumPad2) & !PrevState.IsKeyDown(Keys.NumPad2))
             * {
             *  Player2.AddForces(new RifleForce(gameTime), Player1, gameTime);
             * }
             * if (state.IsKeyDown(Keys.NumPad3) & !PrevState.IsKeyDown(Keys.NumPad3))
             * {
             *  Player2.AddForces(new RocketForce(gameTime), Player1, gameTime);
             * }
             * if (state.IsKeyDown(Keys.NumPad4) & !PrevState.IsKeyDown(Keys.NumPad4))
             * {
             *  Player2.AddForces(new DroneCarrierForce(gameTime), Player1, gameTime);
             * }
             * if (state.IsKeyDown(Keys.NumPad5) & !PrevState.IsKeyDown(Keys.NumPad5))
             * {
             *
             *  Player2.AddForces(new CannonForce(gameTime), Player1, gameTime);
             * }
             * //TEMP UPGRADING ENEMY
             * if (state.IsKeyDown(Keys.NumPad0) & !PrevState.IsKeyDown(Keys.NumPad0))
             * {
             *  Player2.Upgrade((ForcesType)0);
             * }
             * if (state.IsKeyDown(Keys.NumPad6) & !PrevState.IsKeyDown(Keys.NumPad6))
             * {
             *  Player2.Upgrade((ForcesType)1);
             * }
             * if (state.IsKeyDown(Keys.NumPad7) & !PrevState.IsKeyDown(Keys.NumPad7))
             * {
             *  Player2.Upgrade((ForcesType)2);
             * }
             * if (state.IsKeyDown(Keys.NumPad8) & !PrevState.IsKeyDown(Keys.NumPad8))
             * {
             *  Player2.Upgrade((ForcesType)3);
             * }
             * if (state.IsKeyDown(Keys.NumPad9) & !PrevState.IsKeyDown(Keys.NumPad9))
             * {
             *  Player2.Upgrade((ForcesType)4);
             * }
             * //testing engine
             * if (state.IsKeyDown(Keys.Space) & !PrevState.IsKeyDown(Keys.Space))
             * {
             *  //GameEventEngine.Add(new GameEventDelayed(() => { tmpColor = Color.Red; },1.0f));
             *  //GameEventEngine.Add(new GameEventDelayed(() => { tmpColor = Color.Green; }, 2.0f));
             *  //GameEventEngine.Add(new GameEventDelayed(() => { tmpColor = Color.Black; }, 3.0f));
             *  //GameEventEngine.Add(new GameEventCyclic(() => { tmpColor = Color.Red; }, 2, 5));
             * }
             */

            PrevState = state;
        }