diff --git a/newton-4.00/applications/media/newtonIcon.png b/newton-4.00/applications/media/newtonIcon.png new file mode 100644 index 000000000..0282569fc Binary files /dev/null and b/newton-4.00/applications/media/newtonIcon.png differ diff --git a/newton-4.00/applications/ndSandbox/demos/ndAdvancedIndustrialRobot.cpp b/newton-4.00/applications/ndSandbox/demos/ndAdvancedIndustrialRobot.cpp index 03150871e..d1337b7e3 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndAdvancedIndustrialRobot.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndAdvancedIndustrialRobot.cpp @@ -526,8 +526,8 @@ namespace ndAdvancedRobot ndFloat32 dy = m_targetLocation.m_y - currenPosit.m_y; ndFloat32 dAzimuth = ndAnglesSub(m_targetLocation.m_azimuth, azimuth); - ndFloat32 azimuth2 = dAzimuth * dAzimuth; - ndFloat32 positError2 = dx * dx + dy * dy; + //ndFloat32 azimuth2 = dAzimuth * dAzimuth; + //ndFloat32 positError2 = dx * dx + dy * dy; #ifdef ND_USE_EULERS ndVector euler1; @@ -535,19 +535,16 @@ namespace ndAdvancedRobot ndFloat32 deltaYaw = ndAnglesSub(euler.m_y, m_targetLocation.m_yaw); ndFloat32 deltaRoll = ndAnglesSub(euler.m_z, m_targetLocation.m_roll); ndFloat32 deltaPitch = ndAnglesSub(euler.m_x, m_targetLocation.m_pitch); - //ndFloat32 angleError2 = deltaYaw * deltaYaw + deltaRoll * deltaRoll + deltaPitch * deltaPitch; - ndFloat32 positReward = ndExp(-100.0f * positError2); - ndFloat32 azimuthReward = ndExp(-100.0f * azimuth2); + ndFloat32 posit_xReward = ndExp(-100.0f * dx * dx); + ndFloat32 posit_yReward = ndExp(-100.0f * dy * dy); + ndFloat32 azimuthReward = ndExp(-100.0f * dAzimuth * dAzimuth); ndFloat32 yawReward = ndExp(-100.0f * deltaYaw * deltaYaw); ndFloat32 rollReward = ndExp(-100.0f * deltaRoll * deltaRoll); ndFloat32 pitchReward = ndExp(-100.0f * deltaPitch * deltaPitch); - ndFloat32 rotatWeight = 0.7f; - ndFloat32 positWeight = 0.3f; - - return positWeight * (positReward * 0.4f + azimuthReward * 0.6f) + - rotatWeight * (yawReward * 0.34f + rollReward * 0.33f + pitchReward * 0.33f); + ndFloat32 rewardWeight = 1.0 / 6.0f; + return rewardWeight * (posit_xReward + posit_yReward + azimuthReward + yawReward + rollReward + pitchReward); #else ndQuaternion effectorRotation(effectorMatrix); @@ -1054,8 +1051,8 @@ namespace ndAdvancedRobot ,m_maxScore(ndFloat32(-1.0e10f)) ,m_discountFactor(0.99f) ,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor)) - ,m_lastEpisode(-1) - ,m_stopTraining(2000 * 1000000) + ,m_lastEpisode(0xffffffff) + ,m_stopTraining(ndUnsigned32(4000) * ndUnsigned32(1000000)) ,m_modelIsTrained(false) { m_outFile = fopen("robotArmReach-vpg.csv", "wb"); @@ -1189,10 +1186,10 @@ namespace ndAdvancedRobot virtual void Update(ndDemoEntityManager* const manager, ndFloat32) { - ndInt32 stopTraining = m_master->GetFramesCount(); + ndUnsigned32 stopTraining = m_master->GetFramesCount(); if (stopTraining <= m_stopTraining) { - ndInt32 episodeCount = m_master->GetEposideCount(); + ndUnsigned32 episodeCount = m_master->GetEposideCount(); m_master->OptimizeStep(); episodeCount -= m_master->GetEposideCount(); @@ -1242,8 +1239,8 @@ namespace ndAdvancedRobot ndFloat32 m_maxScore; ndFloat32 m_discountFactor; ndFloat32 m_horizon; - ndInt32 m_lastEpisode; - ndInt32 m_stopTraining; + ndUnsigned32 m_lastEpisode; + ndUnsigned32 m_stopTraining; bool m_modelIsTrained; }; } diff --git a/newton-4.00/applications/ndSandbox/demos/ndCartpoleContinue.cpp b/newton-4.00/applications/ndSandbox/demos/ndCartpoleContinue.cpp index 16ee0048d..efa732000 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndCartpoleContinue.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndCartpoleContinue.cpp @@ -301,7 +301,7 @@ namespace ndCarpole_1 ,m_maxScore(ndFloat32(-1.0e10f)) ,m_discountFactor(0.99f) ,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor)) - ,m_lastEpisode(-1) + ,m_lastEpisode(0xfffffff) ,m_stopTraining(100 * 1000000) ,m_modelIsTrained(false) { @@ -448,10 +448,10 @@ namespace ndCarpole_1 virtual void Update(ndDemoEntityManager* const manager, ndFloat32) { - ndInt32 stopTraining = m_master->GetFramesCount(); + ndUnsigned32 stopTraining = m_master->GetFramesCount(); if (stopTraining <= m_stopTraining) { - ndInt32 episodeCount = m_master->GetEposideCount(); + ndUnsigned32 episodeCount = m_master->GetEposideCount(); m_master->OptimizeStep(); episodeCount -= m_master->GetEposideCount(); @@ -503,8 +503,8 @@ namespace ndCarpole_1 ndFloat32 m_maxScore; ndFloat32 m_discountFactor; ndFloat32 m_horizon; - ndInt32 m_lastEpisode; - ndInt32 m_stopTraining; + ndUnsigned32 m_lastEpisode; + ndUnsigned32 m_stopTraining; bool m_modelIsTrained; }; } diff --git a/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_1.cpp b/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_1.cpp index f2e0bd9dc..833fd25e0 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_1.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_1.cpp @@ -1256,7 +1256,7 @@ namespace ndQuadruped_1 ,m_maxScore(ndFloat32(-1.0e10f)) ,m_discountFactor(0.995f) ,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor)) - ,m_lastEpisode(-1) + ,m_lastEpisode(0xffffffff) ,m_stopTraining(500 * 1000000) ,m_modelIsTrained(false) { @@ -1399,10 +1399,10 @@ namespace ndQuadruped_1 virtual void Update(ndDemoEntityManager* const manager, ndFloat32) { - ndInt32 stopTraining = m_master->GetFramesCount(); + ndUnsigned32 stopTraining = m_master->GetFramesCount(); if (stopTraining <= m_stopTraining) { - ndInt32 episodeCount = m_master->GetEposideCount(); + ndUnsigned32 episodeCount = m_master->GetEposideCount(); m_master->OptimizeStep(); episodeCount -= m_master->GetEposideCount(); @@ -1452,8 +1452,8 @@ namespace ndQuadruped_1 ndFloat32 m_maxScore; ndFloat32 m_discountFactor; ndFloat32 m_horizon; - ndInt32 m_lastEpisode; - ndInt32 m_stopTraining; + ndUnsigned32 m_lastEpisode; + ndUnsigned32 m_stopTraining; bool m_modelIsTrained; }; } diff --git a/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_2.cpp b/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_2.cpp index 6fb13e868..adeb9ff58 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_2.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_2.cpp @@ -1396,7 +1396,7 @@ namespace ndQuadruped_2 ,m_maxScore(ndFloat32(-1.0e10f)) ,m_discountFactor(0.995f) ,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor)) - ,m_lastEpisode(-1) + ,m_lastEpisode(0xffffffff) ,m_stopTraining(300 * 1000000) ,m_modelIsTrained(false) { @@ -1541,10 +1541,10 @@ namespace ndQuadruped_2 virtual void Update(ndDemoEntityManager* const manager, ndFloat32) { - ndInt32 stopTraining = m_master->GetFramesCount(); + ndUnsigned32 stopTraining = m_master->GetFramesCount(); if (stopTraining <= m_stopTraining) { - ndInt32 episodeCount = m_master->GetEposideCount(); + ndUnsigned32 episodeCount = m_master->GetEposideCount(); m_master->OptimizeStep(); episodeCount -= m_master->GetEposideCount(); @@ -1594,8 +1594,8 @@ namespace ndQuadruped_2 ndFloat32 m_maxScore; ndFloat32 m_discountFactor; ndFloat32 m_horizon; - ndInt32 m_lastEpisode; - ndInt32 m_stopTraining; + ndUnsigned32 m_lastEpisode; + ndUnsigned32 m_stopTraining; bool m_modelIsTrained; }; } diff --git a/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_3.cpp b/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_3.cpp index 9347cf76e..a185c9dad 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_3.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_3.cpp @@ -1321,7 +1321,7 @@ namespace ndQuadruped_3 ,m_maxScore(ndFloat32(-1.0e10f)) ,m_discountFactor(0.99f) ,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor)) - ,m_lastEpisode(-1) + ,m_lastEpisode(0xffffffff) ,m_stopTraining(500 * 1000000) ,m_modelIsTrained(false) { @@ -1485,10 +1485,10 @@ namespace ndQuadruped_3 virtual void Update(ndDemoEntityManager* const manager, ndFloat32) { - ndInt32 stopTraining = m_master->GetFramesCount(); + ndUnsigned32 stopTraining = m_master->GetFramesCount(); if (stopTraining <= m_stopTraining) { - ndInt32 episodeCount = m_master->GetEposideCount(); + ndUnsigned32 episodeCount = m_master->GetEposideCount(); m_master->OptimizeStep(); episodeCount -= m_master->GetEposideCount(); @@ -1539,8 +1539,8 @@ namespace ndQuadruped_3 ndFloat32 m_maxScore; ndFloat32 m_discountFactor; ndFloat32 m_horizon; - ndInt32 m_lastEpisode; - ndInt32 m_stopTraining; + ndUnsigned32 m_lastEpisode; + ndUnsigned32 m_stopTraining; bool m_modelIsTrained; }; #else diff --git a/newton-4.00/applications/ndSandbox/demos/ndUnicycle.cpp b/newton-4.00/applications/ndSandbox/demos/ndUnicycle.cpp index 744034c63..83e8ae44d 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndUnicycle.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndUnicycle.cpp @@ -494,7 +494,7 @@ namespace ndUnicycle ,m_maxScore(ndFloat32(-1.0e10f)) ,m_discountFactor(0.99f) ,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor)) - ,m_lastEpisode(-1) + ,m_lastEpisode(0xffffffff) ,m_stopTraining(200 * 1000000) ,m_modelIsTrained(false) { @@ -637,10 +637,10 @@ namespace ndUnicycle virtual void Update(ndDemoEntityManager* const manager, ndFloat32) { - ndInt32 stopTraining = m_master->GetFramesCount(); + ndUnsigned32 stopTraining = m_master->GetFramesCount(); if (stopTraining <= m_stopTraining) { - ndInt32 episodeCount = m_master->GetEposideCount(); + ndUnsigned32 episodeCount = m_master->GetEposideCount(); m_master->OptimizeStep(); episodeCount -= m_master->GetEposideCount(); @@ -690,8 +690,8 @@ namespace ndUnicycle ndFloat32 m_maxScore; ndFloat32 m_discountFactor; ndFloat32 m_horizon; - ndInt32 m_lastEpisode; - ndInt32 m_stopTraining; + ndUnsigned32 m_lastEpisode; + ndUnsigned32 m_stopTraining; bool m_modelIsTrained; }; } diff --git a/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.cpp b/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.cpp index dcfa919cb..3ac39e39a 100644 --- a/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.cpp +++ b/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.cpp @@ -342,8 +342,8 @@ ndBrainAgentContinuePolicyGradient_TrainerMaster::ndBrainAgentContinuePolicyGrad ,m_criticLearnRate(hyperParameters.m_criticLearnRate) ,m_numberOfActions(hyperParameters.m_numberOfActions) ,m_numberOfObservations(hyperParameters.m_numberOfObservations) - ,m_frameCount(0) ,m_framesAlive(0) + ,m_frameCount(0) ,m_eposideCount(0) ,m_bashBufferSize(hyperParameters.m_bashBufferSize) ,m_maxTrajectorySteps(hyperParameters.m_maxTrajectorySteps) @@ -499,7 +499,7 @@ ndBrainAgentContinuePolicyGradient_Trainer::ndRandomGenerator* ndBrainAgentConti return &m_randomGenerator[m_randomSeed]; } -ndInt32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetFramesCount() const +ndUnsigned32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetFramesCount() const { return m_frameCount; } @@ -509,7 +509,7 @@ bool ndBrainAgentContinuePolicyGradient_TrainerMaster::IsSampling() const return false; } -ndInt32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetEposideCount() const +ndUnsigned32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetEposideCount() const { return m_eposideCount; } diff --git a/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.h b/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.h index cbbffced6..f154f2588 100644 --- a/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.h +++ b/newton-4.00/sdk/dBrain/ndBrainAgentContinuePolicyGradient_Trainer.h @@ -146,8 +146,8 @@ class ndBrainAgentContinuePolicyGradient_TrainerMaster : public ndBrainThreadPoo const ndString& GetName() const; void SetName(const ndString& name); - ndInt32 GetFramesCount() const; - ndInt32 GetEposideCount() const; + ndUnsigned32 GetFramesCount() const; + ndUnsigned32 GetEposideCount() const; bool IsSampling() const; ndFloat32 GetAverageScore() const; @@ -181,9 +181,9 @@ class ndBrainAgentContinuePolicyGradient_TrainerMaster : public ndBrainThreadPoo ndBrainFloat m_criticLearnRate; ndInt32 m_numberOfActions; ndInt32 m_numberOfObservations; - ndInt32 m_frameCount; ndInt32 m_framesAlive; - ndInt32 m_eposideCount; + ndUnsigned32 m_frameCount; + ndUnsigned32 m_eposideCount; ndInt32 m_bashBufferSize; ndInt32 m_maxTrajectorySteps; ndInt32 m_extraTrajectorySteps; diff --git a/newton-4.00/sdk/dCollision/ndMeshEffect.h b/newton-4.00/sdk/dCollision/ndMeshEffect.h index 03dbeae30..43191f04b 100644 --- a/newton-4.00/sdk/dCollision/ndMeshEffect.h +++ b/newton-4.00/sdk/dCollision/ndMeshEffect.h @@ -417,7 +417,7 @@ class ndMeshEffect: public ndPolyhedra ,m_opacity(ndFloat32(1.0f)) ,m_shiness(ndFloat32 (60.0f)) { - strcpy(m_textureName, "default.png"); + strcpy_s(m_textureName, sizeof(m_textureName), "default.png"); } ndVector m_ambient; diff --git a/newton-4.00/sdk/dCore/ndThread.h b/newton-4.00/sdk/dCore/ndThread.h index 2d577b084..61c1fc463 100644 --- a/newton-4.00/sdk/dCore/ndThread.h +++ b/newton-4.00/sdk/dCore/ndThread.h @@ -31,7 +31,7 @@ class ndThreadName public: ndThreadName() { - strcpy(m_name, "newtonWorker"); + strcpy_s(m_name, sizeof(m_name), "newtonWorker"); } char m_name[32]; };