1
0
mirror of https://github.com/veden/Rampant.git synced 2025-09-16 09:16:43 +02:00

see readme

This commit is contained in:
Aaron Veden
2016-10-30 20:24:14 -07:00
parent becacafe84
commit a098591564
9 changed files with 157 additions and 149 deletions

View File

@@ -34,6 +34,12 @@ Base Expansion
# 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 -
- Fixed a bug in the processing queue when upgrading mod
- 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
- Optimization to offset ai created bases scanning
0.13.5 = 0.14.5
0.13.4 = 0.14.4
0.13.3 = 0.14.3

View File

@@ -18,7 +18,7 @@ config.attackWaveGenerationUsePlayerProximity = true
starts 20 @ 0.0 evolution
ends 0 @ 100.0 evolution
default max is 20
default min is 00
default min is 0
--]]
config.attackWaveGenerationThresholdMax = 20
config.attackWaveGenerationThresholdMin = 0

View File

@@ -1,7 +1,7 @@
{
"name" : "Rampant",
"factorio_version" : "0.14",
"version" : "0.14.4",
"version" : "0.14.5",
"title" : "Rampant AI",
"author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",

View File

@@ -30,12 +30,12 @@ local CONFIG_ATTACK_WAVE_MAX_SIZE = config.attackWaveMaxSize
-- imported functions
local getCardinalChunksWithDirection = mapUtils.getCardinalChunksWithDirection
local getNeighborChunksWithDirection = mapUtils.getNeighborChunksWithDirection
local getChunkByPosition = mapUtils.getChunkByPosition
local canMoveChunkDirectionCardinal = mapUtils.canMoveChunkDirectionCardinal
local canMoveChunkDirection = mapUtils.canMoveChunkDirection
local addSquadMovementPenalty = unitGroupUtils.addSquadMovementPenalty
local lookupSquadMovementPenalty = unitGroupUtils.lookupSquadMovementPenalty
local positionFromDirectionAndChunkCardinal = mapUtils.positionFromDirectionAndChunkCardinal
local positionFromDirectionAndChunk = mapUtils.positionFromDirectionAndChunk
local euclideanDistanceNamed = mapUtils.euclideanDistanceNamed
@@ -48,12 +48,12 @@ local mLog = math.log10
-- module code
local function validLocation(x, chunk, neighborChunk)
return canMoveChunkDirectionCardinal(x, chunk, neighborChunk)
return canMoveChunkDirection(x, chunk, neighborChunk)
end
local function scoreAttackLocation(position, squad, neighborChunk, surface)
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
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
local chunk = getChunkByPosition(regionMap, group.position.x, group.position.y)
if (chunk ~= nil) then
addSquadMovementPenalty(squad, chunk.cX, chunk.cY)
local attackChunk, attackDirection = scoreNeighborsWithDirection(chunk,
getCardinalChunksWithDirection(regionMap, chunk.cX, chunk.cY),
getNeighborChunksWithDirection(regionMap, chunk.cX, chunk.cY),
validLocation,
scoreAttackLocation,
squad,
surface,
attackPosition)
addSquadMovementPenalty(squad, chunk.cX, chunk.cY)
if (attackChunk ~= nil) then
if (attackChunk[PLAYER_BASE_GENERATOR] == 0) or
((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

View File

@@ -25,9 +25,6 @@ local SQUAD_SUICIDE_RAID = constants.SQUAD_SUICIDE_RAID
local RETREAT_FILTER = constants.RETREAT_FILTER
local NORTH_SOUTH_PASSABLE = constants.NORTH_SOUTH_PASSABLE
local EAST_WEST_PASSABLE = constants.EAST_WEST_PASSABLE
-- imported functions
local getChunkByPosition = mapUtils.getChunkByPosition
@@ -37,16 +34,17 @@ local addSquadMovementPenalty = unitGroupUtils.addSquadMovementPenalty
local createSquad = unitGroupUtils.createSquad
local membersToSquad = unitGroupUtils.membersToSquad
local scoreNeighborsWithDirection = neighborUtils.scoreNeighborsWithDirection
local canMoveChunkDirection = mapUtils.canMoveChunkDirection
-- module code
local function validRetreatLocation(x, chunk, neighborChunk)
return neighborChunk[NORTH_SOUTH_PASSABLE] and neighborChunk[EAST_WEST_PASSABLE]
return canMoveChunkDirection(x, chunk, neighborChunk)
end
local function scoreRetreatLocation(position, squad, neighborChunk, surface)
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
end

View File

@@ -14,7 +14,7 @@ constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL = 10000
constants.PROCESS_QUEUE_SIZE = 500
constants.SCAN_QUEUE_SIZE = 10
constants.PROCESS_PLAYER_BOUND = 3
constants.PROCESS_PLAYER_BOUND = 4
constants.TICKS_A_SECOND = 60
constants.TICKS_A_MINUTE = constants.TICKS_A_SECOND * 60
@@ -132,68 +132,68 @@ constants.retreatFilter[constants.SQUAD_RETREATING] = true
return constants
--[[ types
inserter
loader
inserter
loader
offshore-pump
accumulator
power-switch
generator
pump
boiler
solar-panel
offshore-pump
accumulator
power-switch
generator
pump
boiler
solar-panel
constant-combinator
arithmetic-combinator
decider-combinator
constant-combinator
arithmetic-combinator
decider-combinator
player-port
rocket-silo
roboport
assembling-machine
mining-drill
lab
beacon
radar
furnace
unit-spawner
player-port
rocket-silo
roboport
assembling-machine
mining-drill
lab
beacon
radar
furnace
unit-spawner
lamp
lamp
land-mine
ammo-turret
wall
gate
electric-turret
fluid-turret
turret
land-mine
ammo-turret
wall
gate
electric-turret
fluid-turret
turret
resource
resource
logistic-robot
construction-robot
unit
player
combat-robot
logistic-robot
construction-robot
unit
player
combat-robot
locomotive
cargo-wagon
car
locomotive
cargo-wagon
car
smart-container
logistic-container
container
storage-tank
smart-container
logistic-container
container
storage-tank
transport-belt
underground-belt
splitter
pipe-to-ground
electric-pole
curved-rail
straight-rail
train-stop
rail-signal
rail-chain-signal
pipe
transport-belt
underground-belt
splitter
pipe-to-ground
electric-pole
curved-rail
straight-rail
train-stop
rail-signal
rail-chain-signal
pipe
]]--

View File

@@ -81,53 +81,66 @@ function mapUtils.getNeighborChunks(regionMap, chunkX, chunkY)
return neighbors
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)
local neighbors = {{d=1},{d=2},{d=3},{d=4},{d=5},{d=6},{d=7},{d=8}}
local xChunks = regionMap[chunkX-1]
if (xChunks ~= nil) then
neighbors[1].c = xChunks[chunkY-1]
neighbors[4].c = xChunks[chunkY]
neighbors[6].c = xChunks[chunkY+1]
neighbors[1].c = xChunks[chunkY-1]
neighbors[4].c = xChunks[chunkY]
neighbors[6].c = xChunks[chunkY+1]
end
xChunks = regionMap[chunkX+1]
if (xChunks ~= nil) then
neighbors[3].c = xChunks[chunkY-1]
neighbors[5].c = xChunks[chunkY]
neighbors[8].c = xChunks[chunkY+1]
neighbors[3].c = xChunks[chunkY-1]
neighbors[5].c = xChunks[chunkY]
neighbors[8].c = xChunks[chunkY+1]
end
xChunks = regionMap[chunkX]
if (xChunks ~= nil) then
neighbors[2].c = xChunks[chunkY-1]
neighbors[7].c = xChunks[chunkY+1]
neighbors[2].c = xChunks[chunkY-1]
neighbors[7].c = xChunks[chunkY+1]
end
return neighbors
end
--[[
1
|
1
|
2- -3
|
4
|
4
]]--
function mapUtils.getCardinalChunksWithDirection(regionMap, chunkX, chunkY)
local neighbors = {{d=1},{d=2},{d=3},{d=4}}
local xChunks = regionMap[chunkX]
if (xChunks ~= nil) then
neighbors[1].c = xChunks[chunkY-1]
neighbors[4].c = xChunks[chunkY+1]
neighbors[1].c = xChunks[chunkY-1]
neighbors[4].c = xChunks[chunkY+1]
end
xChunks = regionMap[chunkX-1]
if (xChunks ~= nil) then
neighbors[2].c = xChunks[chunkY]
neighbors[2].c = xChunks[chunkY]
end
xChunks = regionMap[chunkX+1]
if (xChunks ~= nil) then
neighbors[3].c = xChunks[chunkY]
neighbors[3].c = xChunks[chunkY]
end
return neighbors
end
@@ -136,25 +149,25 @@ function mapUtils.getCardinalChunks(regionMap, chunkX, chunkY)
local neighbors = {1,2,3,4}
local xChunks = regionMap[chunkX]
if (xChunks ~= nil) then
neighbors[1] = xChunks[chunkY-1]
neighbors[4] = xChunks[chunkY+1]
neighbors[1] = xChunks[chunkY-1]
neighbors[4] = xChunks[chunkY+1]
else
neighbors[1] = nil
neighbors[4] = nil
neighbors[1] = nil
neighbors[4] = nil
end
xChunks = regionMap[chunkX-1]
if (xChunks ~= nil) then
neighbors[2] = xChunks[chunkY]
neighbors[2] = xChunks[chunkY]
else
neighbors[2] = nil
neighbors[2] = nil
end
xChunks = regionMap[chunkX+1]
if (xChunks ~= nil) then
neighbors[3] = xChunks[chunkY]
neighbors[3] = xChunks[chunkY]
else
neighbors[3] = nil
neighbors[3] = nil
end
return neighbors
end
@@ -172,18 +185,18 @@ function mapUtils.euclideanDistanceArray(p1, p2)
end
--[[
1
|
1
|
2- -3
|
4
|
4
]]--
function mapUtils.canMoveChunkDirectionCardinal(direction, startChunk, endChunk)
local canMove = false
if ((direction == 1) or (direction == 4)) and startChunk[NORTH_SOUTH_PASSABLE] and endChunk[NORTH_SOUTH_PASSABLE] then
canMove = true
canMove = true
elseif ((direction == 2) or (direction == 3)) and startChunk[EAST_WEST_PASSABLE] and endChunk[EAST_WEST_PASSABLE] then
canMove = true
canMove = true
end
return canMove
end
@@ -191,66 +204,47 @@ end
function mapUtils.positionFromDirectionAndChunkCardinal(direction, startPosition, position)
-- local position = {x=0,y=0}
if (direction == 1) then
position.x = startPosition.x
position.y = startPosition.y - CHUNK_SIZE
position.x = startPosition.x
position.y = startPosition.y - CHUNK_SIZE
elseif (direction == 2) then
position.x = startPosition.x - CHUNK_SIZE
position.y = startPosition.y
position.x = startPosition.x - CHUNK_SIZE
position.y = startPosition.y
elseif (direction == 3) then
position.x = startPosition.x + CHUNK_SIZE
position.y = startPosition.y
position.x = startPosition.x + CHUNK_SIZE
position.y = startPosition.y
elseif (direction == 4) then
position.x = startPosition.x
position.y = startPosition.y + CHUNK_SIZE
position.x = startPosition.x
position.y = startPosition.y + CHUNK_SIZE
end
-- return position
end
-- function mapUtils.positionFromDirectionAndChunkCardinal(direction, chunk, position)
-- -- 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}
function mapUtils.positionFromDirectionAndChunk(direction, startPosition, position)
-- local position = {x=0, y=0}
if (direction == 1) then
position.x = chunk.pX
position.y = chunk.pY
position.x = startPosition.x - CHUNK_SIZE
position.y = startPosition.y - CHUNK_SIZE
elseif (direction == 2) then
position.x = chunk.pX + HALF_CHUNK_SIZE
position.y = chunk.pY
position.x = startPosition.x
position.y = startPosition.y - CHUNK_SIZE
elseif (direction == 3) then
position.x = chunk.pX + CHUNK_SIZE
position.y = chunk.pY
position.x = startPosition.x + CHUNK_SIZE
position.y = startPosition.y - CHUNK_SIZE
elseif (direction == 4) then
position.x = chunk.pX
position.y = chunk.pY + HALF_CHUNK_SIZE
position.x = startPosition.x - CHUNK_SIZE
position.y = startPosition.y
elseif (direction == 5) then
position.x = chunk.pX + CHUNK_SIZE
position.y = chunk.pY + HALF_CHUNK_SIZE
position.x = startPosition.x + CHUNK_SIZE
position.y = startPosition.y
elseif (direction == 6) then
position.x = chunk.pX
position.y = chunk.pY + CHUNK_SIZE
position.x = startPosition.x - CHUNK_SIZE
position.y = startPosition.y + CHUNK_SIZE
elseif (direction == 7) then
position.x = chunk.pX + HALF_CHUNK_SIZE
position.y = chunk.pY + CHUNK_SIZE
position.x = startPosition.x
position.y = startPosition.y + CHUNK_SIZE
elseif (direction == 8) then
position.x = chunk.pX + CHUNK_SIZE
position.y = chunk.pY + CHUNK_SIZE
position.x = startPosition.x + CHUNK_SIZE
position.y = startPosition.y + CHUNK_SIZE
end
return position
end

View File

@@ -28,6 +28,10 @@ function neighborUtils.scoreNeighborsWithDirection(chunk, neighborDirectionChunk
end
end
end
if scoreFunction(position, squad, chunk, surface) > highestScore then
return nil, -1
end
return highestChunk, highestDirection
end
@@ -47,6 +51,10 @@ function neighborUtils.scoreNeighbors(chunk, neighborChunks, validFunction, scor
end
end
end
if scoreFunction(position, squad, chunk, surface) > highestScore then
return nil, -1
end
return highestChunk, highestScore
end

View File

@@ -6,7 +6,7 @@
;(define modFolder "C:/Users/veden/AppData/Roaming/Factorio/mods/")
;(define zipModFolder "C:/Program Files/Factorio_0.14.1/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"
(lambda (port)
(string->jsexpr (port->string port)))))
@@ -73,8 +73,8 @@
(copyDirectory "graphics" modFolder)
(copyDirectory "prototypes" modFolder)))
;; (copyFiles modFolder)
;; (copyFiles zipModFolder)
;;(copyFiles modFolder)
;; (copyFiles zipModFolder)
(makeZip modFolder)
(makeZip zipModFolder)
;;(makeZip zipModFolder)
)