From 1288a5a10a640757e57f6b95d64a94cfa4a61921 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Tue, 11 May 2010 10:40:14 +0200 Subject: [PATCH] Simplify init_safety() In this for is also ready to be tuned....to be continued ;-) No functional change. Signed-off-by: Marco Costalba --- src/evaluate.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index f6fdb198..e3eb0b33 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1104,28 +1104,19 @@ namespace { void init_safety() { - int maxSlope = 30; - int peak = 0x500; - double a = 0.4; - double b = 0.0; + const Value MaxSlope = Value(30); + const Value Peak = Value(1280); Value t[100]; // First setup the base table for (int i = 0; i < 100; i++) { - if (i < b) - t[i] = Value(0); - else - t[i] = Value((int)(a * (i - b) * (i - b))); - } + t[i] = Value(int(0.4 * i * i)); - for (int i = 1; i < 100; i++) - { - if (t[i] - t[i - 1] > maxSlope) - t[i] = t[i - 1] + Value(maxSlope); + if (i > 0) + t[i] = Min(t[i], t[i - 1] + MaxSlope); - if (t[i] > Value(peak)) - t[i] = Value(peak); + t[i] = Min(t[i], Peak); } // Then apply the weights and get the final KingDangerTable[] array -- 2.39.2