static float GetTurnRadius(float speed) { float forwardSpeed = Mathf.Abs(speed); float turnRadius = 0; var curvature = RoboUtils.Scale(0, 5, 0.0069f, 0.00398f, forwardSpeed); if (forwardSpeed >= 500 / 100) { curvature = RoboUtils.Scale(5, 10, 0.00398f, 0.00235f, forwardSpeed); } if (forwardSpeed >= 1000 / 100) { curvature = RoboUtils.Scale(10, 15, 0.00235f, 0.001375f, forwardSpeed); } if (forwardSpeed >= 1500 / 100) { curvature = RoboUtils.Scale(15, 17.5f, 0.001375f, 0.0011f, forwardSpeed); } if (forwardSpeed >= 1750 / 100) { curvature = RoboUtils.Scale(17.5f, 23, 0.0011f, 0.00088f, forwardSpeed); } turnRadius = 1 / (curvature * 100); return(turnRadius); }
private void SavePlayFiles(RoboPosition position, IEnumerable <RoboCard> cards, IEnumerable <RoboPosition> allPlayers) { RoboBoard board = GetBlockingBoard(position, allPlayers); board.Save(WorkingDirectory + "/board.txt"); RoboPosition.SavePosition(WorkingDirectory + "/bot.txt", position); RoboUtils.SaveCardsToFile(WorkingDirectory + "/cards.txt", cards); }
private void DrawForces() { if (_c.isCanDrive != true) { return; } // Draw induced lateral friction Fy RoboUtils.DrawRay(_lateralForcePosition, 0.3f * -Fy * transform.right, Color.magenta); // Draw observed forces RoboUtils.DrawLocalRay(transform, transform.up, _wheelAcceleration.z, transform.forward, Color.gray); }
private void loadKIToolStripMenuItem_Click(object sender, EventArgs e) { if (openKIFileDialog.ShowDialog(this) != DialogResult.OK || openKIFileDialog.FileName.IsNullOrEmpty()) { return; } RoboPlayerPlugin roboPlugin = RoboUtils.RegisterPlugin(RoboManager, openKIFileDialog.FileName); ToolStripMenuItem item = AddPluginToPlayerDropDown(roboPlugin); item.PerformClick(); }
private void loadBoardToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog(this) != DialogResult.OK) { return; } RoboBoard board = RoboUtils.LoadBoard(openFileDialog.FileName, Difficulty.Hard); SetBoard(board); SetBoardEditorVisibility(false); }
public override void StartRound(RoboPosition position, ICollection <RoboCard> cards, IEnumerable <RoboPosition> allPlayers) { SavePlayFiles(position, cards, allPlayers); Exception ex = LaunchProgramm(); if (ex != null) { PlayCards(null, ex); return; } RoboCard[] result = RoboUtils.LoadCards(WorkingDirectory + "/ccards.txt", 5); PlayCards(result); }
private void DrawWheelVelocities() { if (_rb == null) { return; } if (_c.isCanDrive != true) { return; } var offset = 0.05f * transform.up; RoboUtils.DrawRay(_wheelContactPoint + offset, _wheelVelocity * 0.1f, Color.black); RoboUtils.DrawRay(_wheelContactPoint + offset, (_wheelForwardVelocity * 0.1f) * transform.forward, Color.blue); RoboUtils.DrawRay(_wheelContactPoint + offset, (_wheelLateralVelocity * 0.1f) * transform.right, Color.red); }
private void FixedUpdate() { _speedMagnitude = _rb.velocity.magnitude; _speedMagnitudeKmH = _speedMagnitude * 3.6f; var currentAlpha = RoboUtils.Scale(40, 100, 0, 1, _speedMagnitudeKmH); currentAlpha = Mathf.Clamp(currentAlpha, 0, 1); _gradient.alphaKeys = new GradientAlphaKey[] { new GradientAlphaKey(currentAlpha, 0), new GradientAlphaKey(0, 1) }; _trail.colorGradient = _gradient; var maxTrailWidth = 0.6f; var minTrailWidth = 0.3f; var trailWidth = RoboUtils.Scale(40, 80, minTrailWidth, maxTrailWidth, _speedMagnitudeKmH); _trail.startWidth = Mathf.Clamp(trailWidth, minTrailWidth, maxTrailWidth); }
static float GetForwardAcceleration(float speed) { // Replicates acceleration curve from RL, depends on current car forward velocity speed = Mathf.Abs(speed); float throttle = 0; if (speed > (1410 / 100)) { throttle = 0; } else if (speed > (1400 / 100)) { throttle = RoboUtils.Scale(14, 14.1f, 1.6f, 0, speed); } else if (speed <= (1400 / 100)) { throttle = RoboUtils.Scale(0, 14, 16, 1.6f, speed); } return(throttle); }