fix: få stående pixels slår ikke spillets marktilstand — visnede/høstede marker klargøres (1.62.344)

This commit is contained in:
2026-10-18 22:52:45 +02:00
parent 332d723bc0
commit 04a306372c
5 changed files with 26 additions and 9 deletions
+18 -8
View File
@@ -45,13 +45,22 @@ end
-- Markens art: slåafgrøde, høstafgrøde eller bar (ingen afgrøde). Vokser = afgrøde der ikke er klar endnu.
-- Markens vækststadie: prøvepunkternes stemmer (vægtet med areal) frem for spillets ene punkt ved markskiltet
-- (in-game 4/10: F14 stod som "høstet" (10), men 76 % stod endnu på 8 — guiden skjulte aflæsningsvogne)
function ADFields.pickGrowthState(fieldState, votes)
local best, bestWeight = nil, 0
-- Stemmerne tæller kun afgrøde der står (getFruitArea: visnede og høstede pixels tæller ikke). Dækker de en lille del af
-- marken (totalPixels = hele prøvearealet), er det rester i kanten — så gælder spillets marktilstand (in-game 18/10:
-- F96 visnet havre stemt "4" af få grønne pletter; F41 havre spil 7 = høstet, stemmer 4:19; F21 hvede spil 10, 7:21).
-- samme grænse som "høsten er færdig" (ADFieldJobs.HARVEST_DONE_RATIO 0,05): står der mere, høstes resten stadig (review)
ADFields.MIN_VOTE_SHARE = 0.05
function ADFields.pickGrowthState(fieldState, votes, totalPixels)
local best, bestWeight, sum = nil, 0, 0
for state, weight in pairs(votes or {}) do
sum = sum + weight
if weight > bestWeight then best, bestWeight = state, weight end
end
if best ~= nil then return best end
return fieldState
if best == nil then return fieldState end
if fieldState ~= nil and type(totalPixels) == "number" and totalPixels > 0 and sum < ADFields.MIN_VOTE_SHARE * totalPixels then
return fieldState
end
return best
end
function ADFields.classify(fruitIndex, isMowable, readyRatio)
@@ -63,7 +72,7 @@ end
-- Diagnose til scanningsloggen: hvilket vækststadie blev valgt, og hvorfra (spillets marktilstand vs. punkternes
-- stemmer), og afgrødens grænser. In-game 18/10: visnet havre (F96) blev læst som "growing" — stadiet skal kunne ses.
-- -> fx "vækst 4 (spil 6, stemmer 4:120 5:3), høst 5-5, visnet 6, fase growing, art harvest"
function ADFields.growthDiag(gameState, votes, fruit, chosen, phase, kind)
function ADFields.growthDiag(gameState, votes, fruit, chosen, phase, kind, totalPixels)
local states = {}
for state in pairs(votes or {}) do table.insert(states, state) end
table.sort(states)
@@ -71,8 +80,9 @@ function ADFields.growthDiag(gameState, votes, fruit, chosen, phase, kind)
for _, state in ipairs(states) do table.insert(parts, string.format("%d:%d", state, math.floor(votes[state]))) end
local minReady = fruit ~= nil and (fruit.minHarvestingGrowthState or fruit.minHarvestGrowthState) or nil
local maxReady = fruit ~= nil and (fruit.maxHarvestingGrowthState or fruit.maxHarvestGrowthState) or minReady
return string.format("vækst %s (spil %s, stemmer %s), høst %s-%s, visnet %s, fase %s, art %s",
return string.format("vækst %s (spil %s, stemmer %s af %s), høst %s-%s, visnet %s, fase %s, art %s",
tostring(chosen), tostring(gameState), #parts > 0 and table.concat(parts, " ") or "-",
type(totalPixels) == "number" and tostring(math.floor(totalPixels)) or "?",
tostring(minReady), tostring(maxReady), tostring(fruit ~= nil and fruit.witheredState or nil), tostring(phase), tostring(kind))
end
@@ -609,7 +619,7 @@ local function finishScan(adEnv, scan)
end
info.kind = ADFields.classify(info.fruitIndex, info.mowable, info.readyRatio)
local gameGrowth = info.growthState
info.growthState = ADFields.pickGrowthState(info.growthState, scan.stateVotes)
info.growthState = ADFields.pickGrowthState(info.growthState, scan.stateVotes, scan.totalSum)
info.phase = fruit ~= nil and ADFields.growthPhase(info.growthState, fruit) or nil
info.growing = info.fruitIndex ~= nil and ADFields.isGrowing(info.phase, info.anyPixels, info.readyRatio)
-- høstet stub eller visnet afgrøde er i praksis en bar mark (klargøring/såning)
@@ -651,7 +661,7 @@ local function finishScan(adEnv, scan)
state == nil and "ukendt" or (state.noFieldGround and "groundType NONE" or "markjord"),
tostring(info.fruitName or "-"), info.cultivable == false and "NEJ" or "ja")
if fruit ~= nil then
summary = summary .. ", " .. ADFields.growthDiag(gameGrowth, scan.stateVotes, fruit, info.growthState, info.phase, info.kind)
summary = summary .. ", " .. ADFields.growthDiag(gameGrowth, scan.stateVotes, fruit, info.growthState, info.phase, info.kind, scan.totalSum)
end
ADFields.scanLog = ADFields.scanLog or {}
-- også når marken får/mister sin markjord (afgrøde uden markjord-lag -> rigtig mark), in-game 10/10 F2,
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.62.343.0</version>
<version>1.62.344.0</version>
<title>
<en>AD Smart Pickup</en>
</title>