mirror of
https://github.com/veden/Rampant.git
synced 2025-09-16 09:16:43 +02:00
see readme
This commit is contained in:
@@ -34,6 +34,12 @@ Base Expansion
|
|||||||
|
|
||||||
# Version History
|
# Version History
|
||||||
|
|
||||||
|
0.14.5 -
|
||||||
|
- Improvement: Enlarged player processing bubble from 3 to 4 (pheromone radius is still 4)
|
||||||
|
- Fix: Increased player scoring weight, so biter groups correctly hunt once more (https://forums.factorio.com/viewtopic.php?f=94&t=31445#p216119)
|
||||||
|
- Improvement: Adjusted attack pathing, so groups can move diagonally
|
||||||
|
- Fix: Unit group retreating when player occupies same chunk
|
||||||
|
|
||||||
0.14.4 -
|
0.14.4 -
|
||||||
- Fixed a bug in the processing queue when upgrading mod
|
- Fixed a bug in the processing queue when upgrading mod
|
||||||
- Greatly decreased Player pheromone radius, now sits at roughly 4 chunks around the player
|
- Greatly decreased Player pheromone radius, now sits at roughly 4 chunks around the player
|
||||||
@@ -63,6 +69,8 @@ Base Expansion
|
|||||||
- Fixed ai created bases not being counted in logic
|
- Fixed ai created bases not being counted in logic
|
||||||
- Optimization to offset ai created bases scanning
|
- Optimization to offset ai created bases scanning
|
||||||
|
|
||||||
|
0.13.5 = 0.14.5
|
||||||
|
|
||||||
0.13.4 = 0.14.4
|
0.13.4 = 0.14.4
|
||||||
|
|
||||||
0.13.3 = 0.14.3
|
0.13.3 = 0.14.3
|
||||||
|
@@ -18,7 +18,7 @@ config.attackWaveGenerationUsePlayerProximity = true
|
|||||||
starts 20 @ 0.0 evolution
|
starts 20 @ 0.0 evolution
|
||||||
ends 0 @ 100.0 evolution
|
ends 0 @ 100.0 evolution
|
||||||
default max is 20
|
default max is 20
|
||||||
default min is 00
|
default min is 0
|
||||||
--]]
|
--]]
|
||||||
config.attackWaveGenerationThresholdMax = 20
|
config.attackWaveGenerationThresholdMax = 20
|
||||||
config.attackWaveGenerationThresholdMin = 0
|
config.attackWaveGenerationThresholdMin = 0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name" : "Rampant",
|
"name" : "Rampant",
|
||||||
"factorio_version" : "0.14",
|
"factorio_version" : "0.14",
|
||||||
"version" : "0.14.4",
|
"version" : "0.14.5",
|
||||||
"title" : "Rampant AI",
|
"title" : "Rampant AI",
|
||||||
"author" : "Veden",
|
"author" : "Veden",
|
||||||
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
||||||
|
@@ -30,12 +30,12 @@ local CONFIG_ATTACK_WAVE_MAX_SIZE = config.attackWaveMaxSize
|
|||||||
|
|
||||||
-- imported functions
|
-- imported functions
|
||||||
|
|
||||||
local getCardinalChunksWithDirection = mapUtils.getCardinalChunksWithDirection
|
local getNeighborChunksWithDirection = mapUtils.getNeighborChunksWithDirection
|
||||||
local getChunkByPosition = mapUtils.getChunkByPosition
|
local getChunkByPosition = mapUtils.getChunkByPosition
|
||||||
local canMoveChunkDirectionCardinal = mapUtils.canMoveChunkDirectionCardinal
|
local canMoveChunkDirection = mapUtils.canMoveChunkDirection
|
||||||
local addSquadMovementPenalty = unitGroupUtils.addSquadMovementPenalty
|
local addSquadMovementPenalty = unitGroupUtils.addSquadMovementPenalty
|
||||||
local lookupSquadMovementPenalty = unitGroupUtils.lookupSquadMovementPenalty
|
local lookupSquadMovementPenalty = unitGroupUtils.lookupSquadMovementPenalty
|
||||||
local positionFromDirectionAndChunkCardinal = mapUtils.positionFromDirectionAndChunkCardinal
|
local positionFromDirectionAndChunk = mapUtils.positionFromDirectionAndChunk
|
||||||
|
|
||||||
local euclideanDistanceNamed = mapUtils.euclideanDistanceNamed
|
local euclideanDistanceNamed = mapUtils.euclideanDistanceNamed
|
||||||
|
|
||||||
@@ -48,12 +48,12 @@ local mLog = math.log10
|
|||||||
-- module code
|
-- module code
|
||||||
|
|
||||||
local function validLocation(x, chunk, neighborChunk)
|
local function validLocation(x, chunk, neighborChunk)
|
||||||
return canMoveChunkDirectionCardinal(x, chunk, neighborChunk)
|
return canMoveChunkDirection(x, chunk, neighborChunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function scoreAttackLocation(position, squad, neighborChunk, surface)
|
local function scoreAttackLocation(position, squad, neighborChunk, surface)
|
||||||
local squadMovementPenalty = lookupSquadMovementPenalty(squad, neighborChunk.cX, neighborChunk.cY)
|
local squadMovementPenalty = lookupSquadMovementPenalty(squad, neighborChunk.cX, neighborChunk.cY)
|
||||||
local r = surface.get_pollution(position) + neighborChunk[MOVEMENT_PHEROMONE] + neighborChunk[BASE_PHEROMONE] + neighborChunk[PLAYER_PHEROMONE]
|
local r = surface.get_pollution(position) + neighborChunk[MOVEMENT_PHEROMONE] + neighborChunk[BASE_PHEROMONE] + (neighborChunk[PLAYER_PHEROMONE] * 25)
|
||||||
return r - squadMovementPenalty
|
return r - squadMovementPenalty
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -75,19 +75,19 @@ function aiAttack.squadAttack(regionMap, surface, natives)
|
|||||||
if (group.state == defines.group_state.finished) or (group.state == defines.group_state.gathering) or ((group.state == defines.group_state.moving) and (squad.cycles == 0)) then
|
if (group.state == defines.group_state.finished) or (group.state == defines.group_state.gathering) or ((group.state == defines.group_state.moving) and (squad.cycles == 0)) then
|
||||||
local chunk = getChunkByPosition(regionMap, group.position.x, group.position.y)
|
local chunk = getChunkByPosition(regionMap, group.position.x, group.position.y)
|
||||||
if (chunk ~= nil) then
|
if (chunk ~= nil) then
|
||||||
addSquadMovementPenalty(squad, chunk.cX, chunk.cY)
|
|
||||||
local attackChunk, attackDirection = scoreNeighborsWithDirection(chunk,
|
local attackChunk, attackDirection = scoreNeighborsWithDirection(chunk,
|
||||||
getCardinalChunksWithDirection(regionMap, chunk.cX, chunk.cY),
|
getNeighborChunksWithDirection(regionMap, chunk.cX, chunk.cY),
|
||||||
validLocation,
|
validLocation,
|
||||||
scoreAttackLocation,
|
scoreAttackLocation,
|
||||||
squad,
|
squad,
|
||||||
surface,
|
surface,
|
||||||
attackPosition)
|
attackPosition)
|
||||||
|
addSquadMovementPenalty(squad, chunk.cX, chunk.cY)
|
||||||
if (attackChunk ~= nil) then
|
if (attackChunk ~= nil) then
|
||||||
if (attackChunk[PLAYER_BASE_GENERATOR] == 0) or
|
if (attackChunk[PLAYER_BASE_GENERATOR] == 0) or
|
||||||
((group.state == defines.group_state.finished) or (group.state == defines.group_state.gathering)) then
|
((group.state == defines.group_state.finished) or (group.state == defines.group_state.gathering)) then
|
||||||
|
|
||||||
positionFromDirectionAndChunkCardinal(attackDirection, squad.group.position, attackPosition)
|
positionFromDirectionAndChunk(attackDirection, squad.group.position, attackPosition)
|
||||||
|
|
||||||
squad.cycles = 3
|
squad.cycles = 3
|
||||||
|
|
||||||
|
@@ -25,9 +25,6 @@ local SQUAD_SUICIDE_RAID = constants.SQUAD_SUICIDE_RAID
|
|||||||
|
|
||||||
local RETREAT_FILTER = constants.RETREAT_FILTER
|
local RETREAT_FILTER = constants.RETREAT_FILTER
|
||||||
|
|
||||||
local NORTH_SOUTH_PASSABLE = constants.NORTH_SOUTH_PASSABLE
|
|
||||||
local EAST_WEST_PASSABLE = constants.EAST_WEST_PASSABLE
|
|
||||||
|
|
||||||
-- imported functions
|
-- imported functions
|
||||||
|
|
||||||
local getChunkByPosition = mapUtils.getChunkByPosition
|
local getChunkByPosition = mapUtils.getChunkByPosition
|
||||||
@@ -37,16 +34,17 @@ local addSquadMovementPenalty = unitGroupUtils.addSquadMovementPenalty
|
|||||||
local createSquad = unitGroupUtils.createSquad
|
local createSquad = unitGroupUtils.createSquad
|
||||||
local membersToSquad = unitGroupUtils.membersToSquad
|
local membersToSquad = unitGroupUtils.membersToSquad
|
||||||
local scoreNeighborsWithDirection = neighborUtils.scoreNeighborsWithDirection
|
local scoreNeighborsWithDirection = neighborUtils.scoreNeighborsWithDirection
|
||||||
|
local canMoveChunkDirection = mapUtils.canMoveChunkDirection
|
||||||
|
|
||||||
-- module code
|
-- module code
|
||||||
|
|
||||||
local function validRetreatLocation(x, chunk, neighborChunk)
|
local function validRetreatLocation(x, chunk, neighborChunk)
|
||||||
return neighborChunk[NORTH_SOUTH_PASSABLE] and neighborChunk[EAST_WEST_PASSABLE]
|
return canMoveChunkDirection(x, chunk, neighborChunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function scoreRetreatLocation(position, squad, neighborChunk, surface)
|
local function scoreRetreatLocation(position, squad, neighborChunk, surface)
|
||||||
local safeScore = -neighborChunk[BASE_PHEROMONE] + neighborChunk[MOVEMENT_PHEROMONE]
|
local safeScore = -neighborChunk[BASE_PHEROMONE] + neighborChunk[MOVEMENT_PHEROMONE]
|
||||||
local dangerScore = surface.get_pollution(position) + neighborChunk[PLAYER_PHEROMONE] + (neighborChunk[ENEMY_BASE_GENERATOR] * 6)
|
local dangerScore = surface.get_pollution(position) + (neighborChunk[PLAYER_PHEROMONE] * 25) + (neighborChunk[ENEMY_BASE_GENERATOR] * 6)
|
||||||
return safeScore - dangerScore
|
return safeScore - dangerScore
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL = 10000
|
|||||||
|
|
||||||
constants.PROCESS_QUEUE_SIZE = 500
|
constants.PROCESS_QUEUE_SIZE = 500
|
||||||
constants.SCAN_QUEUE_SIZE = 10
|
constants.SCAN_QUEUE_SIZE = 10
|
||||||
constants.PROCESS_PLAYER_BOUND = 3
|
constants.PROCESS_PLAYER_BOUND = 4
|
||||||
|
|
||||||
constants.TICKS_A_SECOND = 60
|
constants.TICKS_A_SECOND = 60
|
||||||
constants.TICKS_A_MINUTE = constants.TICKS_A_SECOND * 60
|
constants.TICKS_A_MINUTE = constants.TICKS_A_SECOND * 60
|
||||||
|
@@ -81,6 +81,19 @@ function mapUtils.getNeighborChunks(regionMap, chunkX, chunkY)
|
|||||||
return neighbors
|
return neighbors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mapUtils.canMoveChunkDirection(direction, startChunk, endChunk)
|
||||||
|
local canMove = false
|
||||||
|
if ((direction == 2) or (direction == 7)) and startChunk[NORTH_SOUTH_PASSABLE] and endChunk[NORTH_SOUTH_PASSABLE] then
|
||||||
|
canMove = true
|
||||||
|
elseif ((direction == 4) or (direction == 5)) and startChunk[EAST_WEST_PASSABLE] and endChunk[EAST_WEST_PASSABLE] then
|
||||||
|
canMove = true
|
||||||
|
elseif (startChunk[NORTH_SOUTH_PASSABLE] and startChunk[EAST_WEST_PASSABLE] and endChunk[NORTH_SOUTH_PASSABLE] and
|
||||||
|
endChunk[EAST_WEST_PASSABLE]) then
|
||||||
|
canMove = true
|
||||||
|
end
|
||||||
|
return canMove
|
||||||
|
end
|
||||||
|
|
||||||
function mapUtils.getNeighborChunksWithDirection(regionMap, chunkX, chunkY)
|
function mapUtils.getNeighborChunksWithDirection(regionMap, chunkX, chunkY)
|
||||||
local neighbors = {{d=1},{d=2},{d=3},{d=4},{d=5},{d=6},{d=7},{d=8}}
|
local neighbors = {{d=1},{d=2},{d=3},{d=4},{d=5},{d=6},{d=7},{d=8}}
|
||||||
local xChunks = regionMap[chunkX-1]
|
local xChunks = regionMap[chunkX-1]
|
||||||
@@ -206,51 +219,32 @@ function mapUtils.positionFromDirectionAndChunkCardinal(direction, startPosition
|
|||||||
-- return position
|
-- return position
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mapUtils.positionFromDirectionAndChunk(direction, startPosition, position)
|
||||||
-- function mapUtils.positionFromDirectionAndChunkCardinal(direction, chunk, position)
|
-- local position = {x=0, y=0}
|
||||||
-- -- local position = {x=0,y=0}
|
|
||||||
-- if (direction == 1) then
|
|
||||||
-- position.x = chunk.pX + HALF_CHUNK_SIZE
|
|
||||||
-- position.y = chunk.pY
|
|
||||||
-- elseif (direction == 2) then
|
|
||||||
-- position.x = chunk.pX
|
|
||||||
-- position.y = chunk.pY + HALF_CHUNK_SIZE
|
|
||||||
-- elseif (direction == 3) then
|
|
||||||
-- position.x = chunk.pX + CHUNK_SIZE
|
|
||||||
-- position.y = chunk.pY + HALF_CHUNK_SIZE
|
|
||||||
-- elseif (direction == 4) then
|
|
||||||
-- position.x = chunk.pX + HALF_CHUNK_SIZE
|
|
||||||
-- position.y = chunk.pY + CHUNK_SIZE
|
|
||||||
-- end
|
|
||||||
-- -- return position
|
|
||||||
-- end
|
|
||||||
|
|
||||||
function mapUtils.positionFromDirectionAndChunk(direction, chunk)
|
|
||||||
local position = {x=0, y=0}
|
|
||||||
if (direction == 1) then
|
if (direction == 1) then
|
||||||
position.x = chunk.pX
|
position.x = startPosition.x - CHUNK_SIZE
|
||||||
position.y = chunk.pY
|
position.y = startPosition.y - CHUNK_SIZE
|
||||||
elseif (direction == 2) then
|
elseif (direction == 2) then
|
||||||
position.x = chunk.pX + HALF_CHUNK_SIZE
|
position.x = startPosition.x
|
||||||
position.y = chunk.pY
|
position.y = startPosition.y - CHUNK_SIZE
|
||||||
elseif (direction == 3) then
|
elseif (direction == 3) then
|
||||||
position.x = chunk.pX + CHUNK_SIZE
|
position.x = startPosition.x + CHUNK_SIZE
|
||||||
position.y = chunk.pY
|
position.y = startPosition.y - CHUNK_SIZE
|
||||||
elseif (direction == 4) then
|
elseif (direction == 4) then
|
||||||
position.x = chunk.pX
|
position.x = startPosition.x - CHUNK_SIZE
|
||||||
position.y = chunk.pY + HALF_CHUNK_SIZE
|
position.y = startPosition.y
|
||||||
elseif (direction == 5) then
|
elseif (direction == 5) then
|
||||||
position.x = chunk.pX + CHUNK_SIZE
|
position.x = startPosition.x + CHUNK_SIZE
|
||||||
position.y = chunk.pY + HALF_CHUNK_SIZE
|
position.y = startPosition.y
|
||||||
elseif (direction == 6) then
|
elseif (direction == 6) then
|
||||||
position.x = chunk.pX
|
position.x = startPosition.x - CHUNK_SIZE
|
||||||
position.y = chunk.pY + CHUNK_SIZE
|
position.y = startPosition.y + CHUNK_SIZE
|
||||||
elseif (direction == 7) then
|
elseif (direction == 7) then
|
||||||
position.x = chunk.pX + HALF_CHUNK_SIZE
|
position.x = startPosition.x
|
||||||
position.y = chunk.pY + CHUNK_SIZE
|
position.y = startPosition.y + CHUNK_SIZE
|
||||||
elseif (direction == 8) then
|
elseif (direction == 8) then
|
||||||
position.x = chunk.pX + CHUNK_SIZE
|
position.x = startPosition.x + CHUNK_SIZE
|
||||||
position.y = chunk.pY + CHUNK_SIZE
|
position.y = startPosition.y + CHUNK_SIZE
|
||||||
end
|
end
|
||||||
return position
|
return position
|
||||||
end
|
end
|
||||||
|
@@ -29,6 +29,10 @@ function neighborUtils.scoreNeighborsWithDirection(chunk, neighborDirectionChunk
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if scoreFunction(position, squad, chunk, surface) > highestScore then
|
||||||
|
return nil, -1
|
||||||
|
end
|
||||||
|
|
||||||
return highestChunk, highestDirection
|
return highestChunk, highestDirection
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -48,6 +52,10 @@ function neighborUtils.scoreNeighbors(chunk, neighborChunks, validFunction, scor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if scoreFunction(position, squad, chunk, surface) > highestScore then
|
||||||
|
return nil, -1
|
||||||
|
end
|
||||||
|
|
||||||
return highestChunk, highestScore
|
return highestChunk, highestScore
|
||||||
end
|
end
|
||||||
|
|
||||||
|
4
make.rkt
4
make.rkt
@@ -6,7 +6,7 @@
|
|||||||
;(define modFolder "C:/Users/veden/AppData/Roaming/Factorio/mods/")
|
;(define modFolder "C:/Users/veden/AppData/Roaming/Factorio/mods/")
|
||||||
;(define zipModFolder "C:/Program Files/Factorio_0.14.1/mods/")
|
;(define zipModFolder "C:/Program Files/Factorio_0.14.1/mods/")
|
||||||
(define modFolder "/home/veden/.factorio/mods/")
|
(define modFolder "/home/veden/.factorio/mods/")
|
||||||
(define zipModFolder "/data/games/factorio14.14/mods/")
|
(define zipModFolder "/data/games/factorio14.17/mods/")
|
||||||
(define configuration (call-with-input-file "info.json"
|
(define configuration (call-with-input-file "info.json"
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(string->jsexpr (port->string port)))))
|
(string->jsexpr (port->string port)))))
|
||||||
@@ -76,5 +76,5 @@
|
|||||||
;;(copyFiles modFolder)
|
;;(copyFiles modFolder)
|
||||||
;; (copyFiles zipModFolder)
|
;; (copyFiles zipModFolder)
|
||||||
(makeZip modFolder)
|
(makeZip modFolder)
|
||||||
(makeZip zipModFolder)
|
;;(makeZip zipModFolder)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user