private bool[] What_should_I_doJ() { #region input order /* 1. speed * 2.distance * 3.width * 4.can jump */ #endregion inputs[0] = Tools.pm.getEngine(this.ID).velocity.X; List <float> ins = GetAsentialData.findDif(this, Global.bg.obstacleList); if (ins.Count != 0) { inputs[1] = ins[0] / 10; //distamce between obstacle and jump inputs[2] = ins[1] / 10; //obstacle width } else { bool[] answers1 = new bool[outputNum]; answers1[0] = false;; return(answers1); } if (GetAsentialData.CanJump(this)) { inputs[3] = 1; } else { inputs[3] = -1; } //activating neuralNet float[] output = nn.calculate(inputs); //maping the outputs bool[] answers = new bool[outputNum]; for (int i = 0; i < answers.Length; i++) { if (output[i] > 0) { answers[i] = true; } else { answers[i] = false; } } //returning answers return(answers); }
private bool[] What_should_I_doJR() { #region input order /* 1. speed * 2.distance * 3.width * 4.can jump * 5. distance to second group */ #endregion //// setting input inputs[0] = Tools.pm.getEngine(this.ID).velocity.X; // speed List <float> ins = GetAsentialData.findDif(this, Global.bg.obstacleList); // find data for jump inputs[1] = ins[0] / 100; //distamce between obstacle and jump inputs[2] = ins[1] / 10; //obstacle width //if can jump 1 else -1 if (GetAsentialData.CanJump(this)) { inputs[3] = 1; } else { inputs[3] = -1; } //distance to next Obstacle inputs[4] = GetAsentialData.findDifNext(this, Global.bg.obstacleList) / 100; //activating neuralNet float[] output = nn.calculate(inputs); //maping the outputs bool[] answers = new bool[outputNum]; for (int i = 0; i < answers.Length; i++) { if (output[i] > 0) { answers[i] = true; } else { answers[i] = false; } } //returning answers return(answers); }
private bool[] What_should_I_do() { #region input order /* 1. my real poisition.X * 2. my width * 3. my X speed * 4. can I Jump * 5. obstacle Height * 6. first obstacle posX * 7. second obstacle posX * 8. third obstacle posX * 9. fourth obstacle posX * 10. obstacle Width * 11. my scale * 12. an obstacle scale * 13. bullet Left pos */ #endregion //// setting input //float[] inputs = new float[inputNum]; inputs[0] = (this.Position - this.Origin).X; inputs[1] = this.CurrentFrame.Width; inputs[2] = pm.getEngine(ID).velocity.X; //if can jump 1 else 0 if (GetAsentialData.CanJump(this)) { inputs[3] = 1; } else { inputs[3] = 0; } inputs[4] = Global.bg.obstacleList[0].CurrentFrame.Height; inputs[5] = GetAsentialData.GetFirstObstaclePosX(Global.bg.obstacleList, this); inputs[6] = GetAsentialData.GetSecondObstaclePosX(Global.bg.obstacleList, this); inputs[7] = GetAsentialData.GetThirdObstaclePosX(Global.bg.obstacleList, this); inputs[8] = GetAsentialData.GetFourthObstaclePosX(Global.bg.obstacleList, this); inputs[9] = Global.bg.obstacleList[0].CurrentFrame.Width; inputs[10] = this.scale.X; inputs[11] = Global.bg.obstacleList[0].scale.X; inputs[12] = GetAsentialData.GetBulletLeftPosX(); //normalizing all inputs for (int i = 0; i < inputs.Length; i++) { inputs[i] = GetAsentialData.NoramlizeValue(inputs[i]); } //activating neuralNet float[] output = nn.calculate(inputs); //maping the outputs bool[] answers = new bool[outputNum]; for (int i = 0; i < answers.Length; i++) { if (output[i] > 0) { answers[i] = true; } else { answers[i] = false; } } //returning answers return(answers); }