mirror of
https://github.com/veden/Rampant.git
synced 2025-03-17 20:58:35 +02:00
FACTO-169: Updated visualizer tool
This commit is contained in:
parent
b2b6b5db0b
commit
3dabae1057
@ -6,6 +6,8 @@ Version: 3.1.2
|
||||
Bugfixes:
|
||||
- Fixed sent aggressive squads count could be negative
|
||||
- Added missing sent and max siege groups on debug log
|
||||
Framework:
|
||||
- Updated visualizer tool for debugging
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 3.1.1
|
||||
|
425
parseState.rkt
425
parseState.rkt
@ -15,234 +15,225 @@
|
||||
|
||||
|
||||
(module AiState racket
|
||||
(provide (all-defined-out))
|
||||
(provide (all-defined-out))
|
||||
|
||||
(require math/statistics)
|
||||
(require math/statistics)
|
||||
|
||||
(struct AiState (chunks
|
||||
chunksLookup
|
||||
minMaxes)
|
||||
#:transparent)
|
||||
(struct AiState (chunks
|
||||
chunksLookup
|
||||
minMaxes)
|
||||
#:transparent)
|
||||
|
||||
(struct MinMax (min max)
|
||||
#:transparent)
|
||||
(struct MinMax (min max)
|
||||
#:transparent)
|
||||
|
||||
(struct ChunkRange (x
|
||||
y
|
||||
movement
|
||||
base
|
||||
player
|
||||
resource
|
||||
passable
|
||||
tick
|
||||
rating
|
||||
nests
|
||||
worms
|
||||
rally
|
||||
retreat
|
||||
resourceGen
|
||||
playerGen
|
||||
deathGen
|
||||
attackScore
|
||||
settleScore
|
||||
siegeScore
|
||||
retreatScore
|
||||
kamikazeScore
|
||||
pollution
|
||||
aNe
|
||||
aRNe
|
||||
squads
|
||||
baseCreated
|
||||
hives
|
||||
traps
|
||||
utility
|
||||
vg)
|
||||
#:transparent)
|
||||
(struct ChunkRange (x
|
||||
y
|
||||
movement
|
||||
base
|
||||
player
|
||||
resource
|
||||
enemy
|
||||
passable
|
||||
tick
|
||||
rating
|
||||
nests
|
||||
worms
|
||||
rally
|
||||
retreat
|
||||
resourceGen
|
||||
playerGen
|
||||
deathGen
|
||||
scoreResourceKamikaze
|
||||
scoreResource
|
||||
scoreSiegeKamikaze
|
||||
scoreSiege
|
||||
scoreAttackKamikaze
|
||||
scoreAttack
|
||||
pollution
|
||||
aNe
|
||||
aRNe
|
||||
squads
|
||||
baseAlign
|
||||
hives
|
||||
traps
|
||||
utility
|
||||
vg)
|
||||
#:transparent)
|
||||
|
||||
(struct Chunk (kamikazeScore
|
||||
retreatScore
|
||||
siegeScore
|
||||
settleScore
|
||||
attackScore
|
||||
x
|
||||
y
|
||||
movement
|
||||
base
|
||||
player
|
||||
resource
|
||||
passable
|
||||
tick
|
||||
rating
|
||||
nests
|
||||
worms
|
||||
rally
|
||||
retreat
|
||||
resourceGen
|
||||
playerGen
|
||||
deathGen
|
||||
pollution
|
||||
aNe
|
||||
aRNe
|
||||
squads
|
||||
baseCreated
|
||||
hives
|
||||
traps
|
||||
utility
|
||||
vg)
|
||||
#:transparent)
|
||||
(struct Chunk (x
|
||||
y
|
||||
movement
|
||||
base
|
||||
player
|
||||
resource
|
||||
enemy
|
||||
passable
|
||||
tick
|
||||
rating
|
||||
nests
|
||||
worms
|
||||
rally
|
||||
retreat
|
||||
resourceGen
|
||||
playerGen
|
||||
deathGen
|
||||
scoreResourceKamikaze
|
||||
scoreResource
|
||||
scoreSiegeKamikaze
|
||||
scoreSiege
|
||||
scoreAttackKamikaze
|
||||
scoreAttack
|
||||
pollution
|
||||
aNe
|
||||
aRNe
|
||||
squads
|
||||
baseAlign
|
||||
hives
|
||||
traps
|
||||
utility
|
||||
vg)
|
||||
#:transparent)
|
||||
|
||||
(require threading)
|
||||
(require threading)
|
||||
|
||||
(define (getFile filePath)
|
||||
(call-with-input-file filePath
|
||||
(lambda (port)
|
||||
(port->string port))))
|
||||
(define (getFile filePath)
|
||||
(call-with-input-file filePath
|
||||
(lambda (port)
|
||||
(port->string port))))
|
||||
|
||||
(define (stringToChunk str)
|
||||
(match-let (((list movement base player resource passable tick rating x y nest
|
||||
worms rally retreat resourceGen playerGen deathGen pollution aNe aRNe squads
|
||||
baseCreated hives traps utility vg) (string-split str ",")))
|
||||
(apply Chunk
|
||||
(cons (+ (string->number base)
|
||||
(* (string->number player) 100))
|
||||
(cons (+ (- (string->number base))
|
||||
(string->number deathGen)
|
||||
(- (string->number playerGen))
|
||||
(- (* (string->number player) 100)))
|
||||
(cons (+ (string->number resource)
|
||||
(string->number base)
|
||||
(* (string->number player) 100))
|
||||
(cons (+ (- (string->number deathGen))
|
||||
(string->number resource)
|
||||
(- (* (string->number player) 100)))
|
||||
(cons (+ (- (string->number deathGen))
|
||||
(string->number base)
|
||||
(* (string->number player) 100))
|
||||
(map string->number
|
||||
(list x y movement base player resource passable tick rating nest
|
||||
worms rally retreat resourceGen playerGen deathGen pollution aNe
|
||||
aRNe squads baseCreated hives traps utility vg))))))))))
|
||||
|
||||
(define (chunk->string chunk)
|
||||
(string-append "x: " (~v (Chunk-x chunk)) "\n"
|
||||
"y: " (~v (Chunk-y chunk)) "\n"
|
||||
"m: " (~v (Chunk-movement chunk)) "\n"
|
||||
"b: " (~v (Chunk-base chunk)) "\n"
|
||||
"p: " (~v (Chunk-player chunk)) "\n"
|
||||
"r: " (~v (Chunk-resource chunk)) "\n"
|
||||
"pass: " (~v (Chunk-passable chunk)) "\n"
|
||||
"tic: " (~v (Chunk-tick chunk)) "\n"
|
||||
"rat: " (~v (Chunk-rating chunk)) "\n"
|
||||
"ne: " (~v (Chunk-nests chunk)) "\n"
|
||||
"wo: " (~v (Chunk-worms chunk)) "\n"
|
||||
"rall: " (~v (Chunk-rally chunk)) "\n"
|
||||
"retr: " (~v (Chunk-retreat chunk)) "\n"
|
||||
"rGen: " (~v (Chunk-resourceGen chunk)) "\n"))
|
||||
(define (stringToChunk str)
|
||||
(apply Chunk
|
||||
(map string->number
|
||||
(string-split str ","))))
|
||||
|
||||
(define (chunk->string chunk)
|
||||
(string-append "x:" (~v (Chunk-x chunk)) "\n"
|
||||
"y:" (~v (Chunk-y chunk)) "\n"
|
||||
"m:" (~v (Chunk-movement chunk)) "\n"
|
||||
"b:" (~v (Chunk-base chunk)) "\n"
|
||||
"p:" (~v (Chunk-player chunk)) "\n"
|
||||
"r:" (~v (Chunk-resource chunk)) "\n"
|
||||
"e:" (~v (Chunk-enemy chunk)) "\n"
|
||||
"pa:" (~v (Chunk-passable chunk)) "\n"
|
||||
"t:" (~v (Chunk-tick chunk)) "\n"
|
||||
"rat:" (~v (Chunk-rating chunk)) "\n"
|
||||
"ne:" (~v (Chunk-nests chunk)) "\n"
|
||||
"wo:" (~v (Chunk-worms chunk)) "\n"
|
||||
"ral:" (~v (Chunk-rally chunk)) "\n"
|
||||
"ret:" (~v (Chunk-retreat chunk)) "\n"
|
||||
"rG:" (~v (Chunk-resourceGen chunk)) "\n"
|
||||
"pG:" (~v (Chunk-playerGen chunk)) "\n"))
|
||||
|
||||
(define (chunk->string2 chunk)
|
||||
(string-append "pGen: " (~v (Chunk-playerGen chunk)) "\n"
|
||||
"dGen: " (~v (Chunk-deathGen chunk)) "\n"
|
||||
"aSco: " (~v (Chunk-attackScore chunk)) "\n"
|
||||
"sSco: " (~v (Chunk-settleScore chunk)) "\n"
|
||||
"sSei: " (~v (Chunk-siegeScore chunk)) "\n"
|
||||
"sRet: " (~v (Chunk-retreatScore chunk)) "\n"
|
||||
"pol: " (~v (Chunk-pollution chunk)) "\n"
|
||||
"aNe: " (~v (Chunk-aNe chunk)) "\n"
|
||||
"aRNe: " (~v (Chunk-aRNe chunk)) "\n"
|
||||
"sqs: " (~v (Chunk-squads chunk)) "\n"
|
||||
"bC: " (~v (Chunk-baseCreated chunk)) "\n"
|
||||
"H: " (~v (Chunk-hives chunk)) "\n"
|
||||
"T: " (~v (Chunk-traps chunk)) "\n"
|
||||
"U: " (~v (Chunk-utility chunk)) "\n"
|
||||
"vg: " (~v (Chunk-vg chunk)) "\n"))
|
||||
(define (chunk->string2 chunk)
|
||||
(string-append "dG:" (~v (Chunk-deathGen chunk)) "\n"
|
||||
"sA:" (~v (Chunk-scoreAttack chunk)) "\n"
|
||||
"sAK:" (~v (Chunk-scoreAttackKamikaze chunk)) "\n"
|
||||
"sS:" (~v (Chunk-scoreSiege chunk)) "\n"
|
||||
"sSK:" (~v (Chunk-scoreSiegeKamikaze chunk)) "\n"
|
||||
"sR:" (~v (Chunk-scoreResource chunk)) "\n"
|
||||
"sRK:" (~v (Chunk-scoreResourceKamikaze chunk)) "\n"
|
||||
"pu:" (~v (Chunk-pollution chunk)) "\n"
|
||||
"aN:" (~v (Chunk-aNe chunk)) "\n"
|
||||
"aRN:" (~v (Chunk-aRNe chunk)) "\n"
|
||||
"sqs:" (~v (Chunk-squads chunk)) "\n"
|
||||
"bA:" (~v (Chunk-baseAlign chunk)) "\n"
|
||||
"H:" (~v (Chunk-hives chunk)) "\n"
|
||||
"T:" (~v (Chunk-traps chunk)) "\n"
|
||||
"U:" (~v (Chunk-utility chunk)) "\n"
|
||||
"vg:" (~v (Chunk-vg chunk)) "\n"))
|
||||
|
||||
(define (normalizeRange xs)
|
||||
(let* ((sDev (stddev xs))
|
||||
(sMean (mean xs))
|
||||
(target (* 2.5 sDev))
|
||||
(cleanXs (filter (lambda (x)
|
||||
(<= (abs (- x sMean)) target))
|
||||
xs)))
|
||||
(MinMax (apply min cleanXs)
|
||||
(apply max cleanXs))))
|
||||
(define (normalizeRange xs)
|
||||
(let* ((sDev (stddev xs))
|
||||
(sMean (mean xs))
|
||||
(target (* 2.5 sDev))
|
||||
(cleanXs (filter (lambda (x)
|
||||
(<= (abs (- x sMean)) target))
|
||||
xs)))
|
||||
(MinMax (apply min cleanXs)
|
||||
(apply max cleanXs))))
|
||||
|
||||
(define (findChunkPropertiesMinMax chunks)
|
||||
(let ((xs (map Chunk-x chunks))
|
||||
(ys (map Chunk-y chunks))
|
||||
(movements (map Chunk-movement chunks))
|
||||
(bases (map Chunk-base chunks))
|
||||
(players (map Chunk-player chunks))
|
||||
(resources (map Chunk-resource chunks))
|
||||
(passables (map Chunk-passable chunks))
|
||||
(ticks (map Chunk-tick chunks))
|
||||
(ratings (map Chunk-rating chunks))
|
||||
(nests (map Chunk-nests chunks))
|
||||
(worms (map Chunk-worms chunks))
|
||||
(rallys (map Chunk-rally chunks))
|
||||
(retreats (map Chunk-retreat chunks))
|
||||
(rGens (map Chunk-resourceGen chunks))
|
||||
(pGens (map Chunk-playerGen chunks))
|
||||
(dGens (map Chunk-deathGen chunks))
|
||||
(aSco (map Chunk-attackScore chunks))
|
||||
(sSco (map Chunk-settleScore chunks))
|
||||
(sSei (map Chunk-siegeScore chunks))
|
||||
(sRet (map Chunk-retreatScore chunks))
|
||||
(sKam (map Chunk-kamikazeScore chunks))
|
||||
(pol (map Chunk-pollution chunks))
|
||||
(aNe (map Chunk-aNe chunks))
|
||||
(aRNe (map Chunk-aRNe chunks))
|
||||
(sqs (map Chunk-squads chunks))
|
||||
(bC (map Chunk-baseCreated chunks))
|
||||
(H (map Chunk-hives chunks))
|
||||
(T (map Chunk-traps chunks))
|
||||
(U (map Chunk-utility chunks))
|
||||
(vg (map Chunk-vg chunks)))
|
||||
(define (findChunkPropertiesMinMax chunks)
|
||||
(let ((xs (map Chunk-x chunks))
|
||||
(ys (map Chunk-y chunks))
|
||||
(movements (map Chunk-movement chunks))
|
||||
(bases (map Chunk-base chunks))
|
||||
(players (map Chunk-player chunks))
|
||||
(resources (map Chunk-resource chunks))
|
||||
(enemy (map Chunk-enemy chunks))
|
||||
(passables (map Chunk-passable chunks))
|
||||
(ticks (map Chunk-tick chunks))
|
||||
(ratings (map Chunk-rating chunks))
|
||||
(nests (map Chunk-nests chunks))
|
||||
(worms (map Chunk-worms chunks))
|
||||
(rallys (map Chunk-rally chunks))
|
||||
(retreats (map Chunk-retreat chunks))
|
||||
(rGens (map Chunk-resourceGen chunks))
|
||||
(pGens (map Chunk-playerGen chunks))
|
||||
(dGens (map Chunk-deathGen chunks))
|
||||
(sRKs (map Chunk-scoreResourceKamikaze chunks))
|
||||
(sRs (map Chunk-scoreResource chunks))
|
||||
(sSKs (map Chunk-scoreSiegeKamikaze chunks))
|
||||
(sSs (map Chunk-scoreSiege chunks))
|
||||
(sAKs (map Chunk-scoreAttackKamikaze chunks))
|
||||
(sAs (map Chunk-scoreAttack chunks))
|
||||
(pol (map Chunk-pollution chunks))
|
||||
(aNe (map Chunk-aNe chunks))
|
||||
(aRNe (map Chunk-aRNe chunks))
|
||||
(sqs (map Chunk-squads chunks))
|
||||
(bA (map Chunk-baseAlign chunks))
|
||||
(H (map Chunk-hives chunks))
|
||||
(T (map Chunk-traps chunks))
|
||||
(U (map Chunk-utility chunks))
|
||||
(vg (map Chunk-vg chunks)))
|
||||
|
||||
(ChunkRange (MinMax (apply min xs) (apply max xs))
|
||||
(MinMax (apply min ys) (apply max ys))
|
||||
(normalizeRange movements)
|
||||
(normalizeRange bases)
|
||||
(normalizeRange players)
|
||||
(normalizeRange resources)
|
||||
(MinMax (apply min passables) (apply max passables))
|
||||
(normalizeRange ticks)
|
||||
(normalizeRange ratings)
|
||||
(MinMax (apply min nests) (apply max nests))
|
||||
(MinMax (apply min worms) (apply max worms))
|
||||
(MinMax (apply min rallys) (apply max rallys))
|
||||
(MinMax (apply min retreats) (apply max retreats))
|
||||
(MinMax (apply min rGens) (apply max rGens))
|
||||
(MinMax (apply min pGens) (apply max pGens))
|
||||
(MinMax (apply min dGens) (apply max dGens))
|
||||
(normalizeRange aSco)
|
||||
(normalizeRange sSco)
|
||||
(normalizeRange sSei)
|
||||
(normalizeRange sRet)
|
||||
(normalizeRange sKam)
|
||||
(normalizeRange pol)
|
||||
(MinMax (apply min aNe) (apply max aNe))
|
||||
(MinMax (apply min aRNe) (apply max aRNe))
|
||||
(MinMax (apply min sqs) (apply max sqs))
|
||||
(MinMax (apply min bC) (apply max bC))
|
||||
(MinMax (apply min H) (apply max H))
|
||||
(MinMax (apply min T) (apply max T))
|
||||
(MinMax (apply min U) (apply max U))
|
||||
(MinMax (apply min vg) (apply max vg)))
|
||||
))
|
||||
(ChunkRange (MinMax (apply min xs) (apply max xs))
|
||||
(MinMax (apply min ys) (apply max ys))
|
||||
(normalizeRange movements)
|
||||
(normalizeRange bases)
|
||||
(normalizeRange players)
|
||||
(normalizeRange resources)
|
||||
(normalizeRange enemy)
|
||||
(MinMax (apply min passables) (apply max passables))
|
||||
(normalizeRange ticks)
|
||||
(normalizeRange ratings)
|
||||
(MinMax (apply min nests) (apply max nests))
|
||||
(MinMax (apply min worms) (apply max worms))
|
||||
(MinMax (apply min rallys) (apply max rallys))
|
||||
(MinMax (apply min retreats) (apply max retreats))
|
||||
(MinMax (apply min rGens) (apply max rGens))
|
||||
(MinMax (apply min pGens) (apply max pGens))
|
||||
(MinMax (apply min dGens) (apply max dGens))
|
||||
(normalizeRange sRKs)
|
||||
(normalizeRange sRs)
|
||||
(normalizeRange sSKs)
|
||||
(normalizeRange sSs)
|
||||
(normalizeRange sAKs)
|
||||
(normalizeRange sAs)
|
||||
(normalizeRange pol)
|
||||
(MinMax (apply min aNe) (apply max aNe))
|
||||
(MinMax (apply min aRNe) (apply max aRNe))
|
||||
(MinMax (apply min sqs) (apply max sqs))
|
||||
(MinMax (apply min bA) (apply max bA))
|
||||
(MinMax (apply min H) (apply max H))
|
||||
(MinMax (apply min T) (apply max T))
|
||||
(MinMax (apply min U) (apply max U))
|
||||
(MinMax (apply min vg) (apply max vg)))
|
||||
))
|
||||
|
||||
(define (readState filePath)
|
||||
(let* ((replayChunks (getFile filePath))
|
||||
(chunks (map stringToChunk (string-split replayChunks "\n")))
|
||||
(minMaxes (findChunkPropertiesMinMax chunks)))
|
||||
(AiState chunks
|
||||
(apply hash
|
||||
(apply append
|
||||
(map (lambda (chunk)
|
||||
(list (list (Chunk-x chunk)
|
||||
(Chunk-y chunk))
|
||||
chunk))
|
||||
chunks)))
|
||||
minMaxes)))
|
||||
(define (readState filePath)
|
||||
(let* ((replayChunks (getFile filePath))
|
||||
(chunks (map stringToChunk (string-split replayChunks "\n")))
|
||||
(minMaxes (findChunkPropertiesMinMax chunks)))
|
||||
(AiState chunks
|
||||
(apply hash
|
||||
(apply append
|
||||
(map (lambda (chunk)
|
||||
(list (list (Chunk-x chunk)
|
||||
(Chunk-y chunk))
|
||||
chunk))
|
||||
chunks)))
|
||||
minMaxes)))
|
||||
|
||||
(define (test)
|
||||
(AiState-minMaxes (readState "/data/games/factorio/script-output/rampantState.txt"))))
|
||||
(define (test)
|
||||
(AiState-minMaxes (readState "/data/games/factorio/script-output/rampantState.txt"))))
|
||||
|
56
tests.lua
56
tests.lua
@ -426,6 +426,49 @@ local function lookupIndexFaction(targetFaction)
|
||||
return 0
|
||||
end
|
||||
|
||||
local function scoreResourceLocationKamikaze(_, neighborChunk)
|
||||
local settle = neighborChunk[constants.RESOURCE_PHEROMONE]
|
||||
return settle
|
||||
- (neighborChunk[constants.PLAYER_PHEROMONE] * constants.PLAYER_PHEROMONE_MULTIPLER)
|
||||
- neighborChunk[constants.ENEMY_PHEROMONE]
|
||||
end
|
||||
|
||||
local function scoreSiegeLocationKamikaze(_, neighborChunk)
|
||||
local settle = neighborChunk[constants.BASE_PHEROMONE]
|
||||
+ neighborChunk[constants.RESOURCE_PHEROMONE] * 0.5
|
||||
+ (neighborChunk[constants.PLAYER_PHEROMONE] * constants.PLAYER_PHEROMONE_MULTIPLER)
|
||||
- neighborChunk[constants.ENEMY_PHEROMONE]
|
||||
|
||||
return settle
|
||||
end
|
||||
|
||||
local function scoreResourceLocation(map, neighborChunk)
|
||||
local settle = (chunkPropertyUtils.getDeathGeneratorRating(map, neighborChunk) * neighborChunk[constants.RESOURCE_PHEROMONE])
|
||||
return settle
|
||||
- (neighborChunk[constants.PLAYER_PHEROMONE] * constants.PLAYER_PHEROMONE_MULTIPLER)
|
||||
- neighborChunk[constants.ENEMY_PHEROMONE]
|
||||
end
|
||||
|
||||
local function scoreSiegeLocation(map, neighborChunk)
|
||||
local settle = neighborChunk[constants.BASE_PHEROMONE]
|
||||
+ neighborChunk[constants.RESOURCE_PHEROMONE] * 0.5
|
||||
+ (neighborChunk[constants.PLAYER_PHEROMONE] * constants.PLAYER_PHEROMONE_MULTIPLER)
|
||||
- neighborChunk[constants.ENEMY_PHEROMONE]
|
||||
|
||||
return settle * chunkPropertyUtils.getDeathGeneratorRating(map, neighborChunk)
|
||||
end
|
||||
|
||||
local function scoreAttackLocation(map, neighborChunk)
|
||||
local damage = neighborChunk[constants.BASE_PHEROMONE] +
|
||||
(neighborChunk[constants.PLAYER_PHEROMONE] * constants.PLAYER_PHEROMONE_MULTIPLER)
|
||||
return damage * chunkPropertyUtils.getDeathGeneratorRating(map, neighborChunk)
|
||||
end
|
||||
|
||||
local function scoreAttackKamikazeLocation(_, neighborChunk)
|
||||
local damage = neighborChunk[constants.BASE_PHEROMONE] + (neighborChunk[constants.PLAYER_PHEROMONE] * constants.PLAYER_PHEROMONE_MULTIPLER)
|
||||
return damage
|
||||
end
|
||||
|
||||
function tests.exportAiState()
|
||||
|
||||
local printState = function ()
|
||||
@ -446,15 +489,16 @@ function tests.exportAiState()
|
||||
end
|
||||
end
|
||||
|
||||
s = s .. table.concat({0,
|
||||
s = s .. table.concat({chunk.x,
|
||||
chunk.y,
|
||||
chunkPropertyUtils.getDeathGeneratorRating(map, chunk),
|
||||
chunk[constants.BASE_PHEROMONE],
|
||||
chunk[constants.PLAYER_PHEROMONE],
|
||||
chunk[constants.RESOURCE_PHEROMONE],
|
||||
chunk[constants.ENEMY_PHEROMONE],
|
||||
chunkPropertyUtils.getPassable(map, chunk),
|
||||
chunk[constants.CHUNK_TICK],
|
||||
chunkPropertyUtils.getPathRating(map, chunk),
|
||||
chunk.x,
|
||||
chunk.y,
|
||||
chunkPropertyUtils.getNestCount(map, chunk),
|
||||
chunkPropertyUtils.getTurretCount(map, chunk),
|
||||
chunkPropertyUtils.getRallyTick(map, chunk),
|
||||
@ -462,6 +506,12 @@ function tests.exportAiState()
|
||||
chunkPropertyUtils.getResourceGenerator(map, chunk),
|
||||
chunkPropertyUtils.getPlayerBaseGenerator(map, chunk),
|
||||
chunkPropertyUtils.getDeathGenerator(map, chunk),
|
||||
scoreResourceLocationKamikaze(map, chunk),
|
||||
scoreResourceLocation(map, chunk),
|
||||
scoreSiegeLocationKamikaze(map, chunk),
|
||||
scoreSiegeLocation(map, chunk),
|
||||
scoreAttackKamikazeLocation(map, chunk),
|
||||
scoreAttackLocation(map, chunk),
|
||||
game.get_surface(game.players[1].surface.index).get_pollution(chunk),
|
||||
chunkPropertyUtils.getNestActiveness(map, chunk),
|
||||
chunkPropertyUtils.getRaidNestActiveness(map, chunk),
|
||||
|
82
visual.rkt
82
visual.rkt
@ -20,7 +20,13 @@
|
||||
|
||||
(define CHUNK_SIZE 32)
|
||||
|
||||
(define INVALID_CHUNK (Chunk -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))
|
||||
(define INVALID_CHUNK (Chunk -1 -1 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0 0 0 0
|
||||
0 0))
|
||||
|
||||
(define windowX 500)
|
||||
(define windowY 0)
|
||||
@ -73,22 +79,26 @@
|
||||
(define activeChunkSetLookup null)
|
||||
(define activeChunkMinMaxSet null)
|
||||
|
||||
(define panel (new panel%
|
||||
(define topPanel (new panel%
|
||||
[parent mainFrame]
|
||||
(alignment '(left top))))
|
||||
|
||||
(define botPanel (new panel%
|
||||
[parent mainFrame]
|
||||
(alignment '(right bottom))))
|
||||
|
||||
(define statusBox (new message%
|
||||
[parent panel]
|
||||
[parent topPanel]
|
||||
[label (~v "")]
|
||||
[vert-margin 16]))
|
||||
(define siteBox (new message%
|
||||
[parent panel]
|
||||
[parent topPanel]
|
||||
[label ""]
|
||||
[vert-margin 30]))
|
||||
(define siteBox2 (new message%
|
||||
[parent panel]
|
||||
[parent topPanel]
|
||||
[label ""]
|
||||
[vert-margin 300]))
|
||||
[horiz-margin 300]))
|
||||
|
||||
(new button%
|
||||
[parent mainFrame]
|
||||
@ -134,60 +144,25 @@
|
||||
canvass))
|
||||
|
||||
(define (showVisual dc aiState)
|
||||
(match-let* (((AiState chunks chunkLookups chunkMinMaxes) aiState)
|
||||
((ChunkRange (MinMax miX maX)
|
||||
(MinMax miY maY)
|
||||
(MinMax minMovement maxMovement)
|
||||
(MinMax minBase maxBase)
|
||||
(MinMax minPlayer maxPlayer)
|
||||
(MinMax minResource maxResource)
|
||||
(MinMax minPassable maxPassable)
|
||||
(MinMax minTick maxTick)
|
||||
(MinMax minRating maxRating)
|
||||
nests
|
||||
worms
|
||||
rally
|
||||
retreat
|
||||
resourceGen
|
||||
playerGen
|
||||
deathGen
|
||||
attackScore
|
||||
settleScore
|
||||
siegeScore
|
||||
retreatScore
|
||||
kamikazeScore
|
||||
pollution
|
||||
aNe
|
||||
aRNe
|
||||
squads
|
||||
baseCreated
|
||||
hives
|
||||
traps
|
||||
utility
|
||||
vg) chunkMinMaxes))
|
||||
|
||||
(set! activeChunkSet chunks)
|
||||
(let* ((chunkMinMaxes (AiState-minMaxes aiState))
|
||||
(minMaxX (ChunkRange-x chunkMinMaxes))
|
||||
(minMaxY (ChunkRange-y chunkMinMaxes)))
|
||||
(set! activeChunkSet (AiState-chunks aiState))
|
||||
(set! activeChunkMinMaxSet chunkMinMaxes)
|
||||
(set! activeChunkSetLookup chunkLookups)
|
||||
(set! activeChunkSetLookup (AiState-chunksLookup aiState))
|
||||
|
||||
(when (Chunk? activeHighlight)
|
||||
(set! activeHighlight (findChunk (Chunk-x activeHighlight)
|
||||
(Chunk-y activeHighlight))))
|
||||
|
||||
(set! minX miX)
|
||||
(set! maxX maX)
|
||||
(set! minY miY)
|
||||
(set! maxY maY)
|
||||
|
||||
;; (display (list minX minY maxX maxY))
|
||||
;; (display "\n")
|
||||
(set! minX (MinMax-min minMaxX))
|
||||
(set! maxX (MinMax-max minMaxX))
|
||||
(set! minY (MinMax-min minMaxY))
|
||||
(set! maxY (MinMax-max minMaxY))
|
||||
|
||||
(set! tileWidth (ceiling (/ windowWidth (+ (abs (/ (- maxX minX) CHUNK_SIZE)) 3))))
|
||||
(set! tileHeight (ceiling (/ windowHeight (+ (abs (/ (- maxY minY) CHUNK_SIZE)) 3))))
|
||||
|
||||
;; (display (list tileWidth tileHeight))
|
||||
;; (display "\n")
|
||||
|
||||
(refresh dc)
|
||||
|
||||
(thread (lambda ()
|
||||
@ -295,9 +270,9 @@
|
||||
|
||||
(new radio-box%
|
||||
[label "Show Layer"]
|
||||
[choices (list "movement" "base" "player" "resource" "passable" "tick" "rating" "nests" "worms" "rally" "retreat" "resourceGen" "playerGen" "deathGen" "attackScore" "settleScore" "siegeScore" "retreatScore" "kamikazeScore" "pollution" "aNe" "aRNe" "squads" "baseCreated" "hives" "traps" "utility" "vg")]
|
||||
[choices (list "movement" "base" "player" "resource" "enemy" "passable" "tick" "rating" "nests" "worms" "rally" "retreat" "resourceGen" "playerGen" "deathGen" "scoreResourceKamikaze" "scoreResource" "scoreSiegeKamikaze" "scoreSiege" "scoreAttackKamikaze" "scoreAttack" "pollution" "aNe" "aRNe" "squads" "baseAlign" "hives" "traps" "utility" "vg")]
|
||||
[selection 0]
|
||||
[parent mainFrame]
|
||||
[parent botPanel]
|
||||
(callback (lambda (radioButton event)
|
||||
(set! activeLayer (send radioButton get-item-label (send radioButton get-selection)))
|
||||
(refresh dcMap))))
|
||||
@ -307,7 +282,4 @@
|
||||
frames))
|
||||
|
||||
(runIt)
|
||||
;; (module Visualizer racket
|
||||
;; (provide (all-defined-out))
|
||||
|
||||
;; )
|
||||
|
Loading…
x
Reference in New Issue
Block a user