2016-08-04 02:22:27 +02:00
|
|
|
local tests = {}
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2016-08-18 07:55:08 +02:00
|
|
|
local constants = require("libs/Constants")
|
2016-11-04 01:51:35 +02:00
|
|
|
local mathUtils = require("libs/MathUtils")
|
2017-05-08 08:56:11 +02:00
|
|
|
local chunkUtils = require("libs/ChunkUtils")
|
2018-02-01 06:01:28 +02:00
|
|
|
local chunkPropertyUtils = require("libs/ChunkPropertyUtils")
|
2017-05-28 06:50:37 +02:00
|
|
|
local mapUtils = require("libs/MapUtils")
|
2017-05-08 08:56:11 +02:00
|
|
|
local baseUtils = require("libs/BaseUtils")
|
2017-11-21 09:27:03 +02:00
|
|
|
-- local tendrilUtils = require("libs/TendrilUtils")
|
2016-08-18 07:55:08 +02:00
|
|
|
|
2017-06-09 07:18:59 +02:00
|
|
|
function tests.pheromoneLevels(size)
|
2016-08-25 01:30:45 +02:00
|
|
|
local player = game.player.character
|
2017-11-21 09:27:03 +02:00
|
|
|
local playerChunkX = math.floor(player.position.x / 32) * constants.CHUNK_SIZE
|
|
|
|
local playerChunkY = math.floor(player.position.y / 32) * constants.CHUNK_SIZE
|
2017-06-09 07:18:59 +02:00
|
|
|
if not size then
|
2017-11-21 09:27:03 +02:00
|
|
|
size = 3 * constants.CHUNK_SIZE
|
|
|
|
else
|
|
|
|
size = size * constants.CHUNK_SIZE
|
2017-06-09 07:18:59 +02:00
|
|
|
end
|
2016-08-04 02:22:27 +02:00
|
|
|
print("------")
|
2018-01-14 07:48:21 +02:00
|
|
|
print(#global.map.processQueue)
|
2016-08-04 02:22:27 +02:00
|
|
|
print(playerChunkX .. ", " .. playerChunkY)
|
|
|
|
print("--")
|
2017-11-21 09:27:03 +02:00
|
|
|
for y=playerChunkY-size, playerChunkY+size,32 do
|
|
|
|
for x=playerChunkX-size, playerChunkX+size,32 do
|
2018-01-14 07:48:21 +02:00
|
|
|
if (global.map[x] ~= nil) then
|
|
|
|
local chunk = global.map[x][y]
|
2016-08-04 02:22:27 +02:00
|
|
|
if (chunk ~= nil) then
|
2016-08-21 23:48:55 +02:00
|
|
|
local str = ""
|
|
|
|
for i=1,#chunk do
|
|
|
|
str = str .. " " .. tostring(i) .. "/" .. tostring(chunk[i])
|
|
|
|
end
|
2018-05-24 02:40:05 +02:00
|
|
|
str = str .. " " .. "p/" .. game.surfaces[global.natives.activeSurface].get_pollution(chunk) .. " " .. "n/" .. chunkPropertyUtils.getNestCount(global.map, chunk) .. " " .. "w/" .. chunkPropertyUtils.getWormCount(global.map, chunk)
|
2017-11-21 09:27:03 +02:00
|
|
|
if (chunk.x == playerChunkX) and (chunk.y == playerChunkY) then
|
2017-06-09 07:18:59 +02:00
|
|
|
print("=============")
|
2017-11-21 09:27:03 +02:00
|
|
|
print(chunk.x, chunk.y, str)
|
2017-06-09 07:18:59 +02:00
|
|
|
print("=============")
|
2016-10-15 02:00:18 +02:00
|
|
|
else
|
2017-11-21 09:27:03 +02:00
|
|
|
print(chunk.x, chunk.y, str)
|
2016-10-15 02:00:18 +02:00
|
|
|
end
|
|
|
|
-- print(str)
|
2017-06-09 07:18:59 +02:00
|
|
|
print("----")
|
2016-08-04 02:22:27 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-09 07:18:59 +02:00
|
|
|
print("------------------")
|
2016-08-04 02:22:27 +02:00
|
|
|
end
|
|
|
|
end
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.activeSquads()
|
2016-08-20 04:52:27 +02:00
|
|
|
print("--")
|
|
|
|
for i=1, #global.natives.squads do
|
2017-11-27 00:10:56 +02:00
|
|
|
print("-")
|
2016-08-20 04:52:27 +02:00
|
|
|
local squad = global.natives.squads[i]
|
2017-11-27 00:10:56 +02:00
|
|
|
local squadHealth = 0
|
|
|
|
local squadMakeup = {}
|
|
|
|
local squadResistances = {}
|
2016-08-18 07:55:08 +02:00
|
|
|
if squad.group.valid then
|
2017-11-27 00:10:56 +02:00
|
|
|
for x=1,#squad.group.members do
|
|
|
|
local member = squad.group.members[x].prototype
|
|
|
|
if not squadMakeup[member.name] then
|
|
|
|
squadMakeup[member.name] = 0
|
|
|
|
end
|
|
|
|
local resistances = member.resistances
|
|
|
|
if resistances then
|
|
|
|
for key,resistance in pairs(resistances) do
|
|
|
|
local pack = squadResistances[key]
|
|
|
|
if not pack then
|
|
|
|
pack = {}
|
|
|
|
squadResistances[key] = pack
|
|
|
|
end
|
|
|
|
if resistance.percent then
|
|
|
|
if (pack.percent == nil) then
|
|
|
|
pack.percent = 0
|
|
|
|
end
|
|
|
|
pack.percent = pack.percent + resistance.percent
|
|
|
|
end
|
|
|
|
if resistance.decrease then
|
|
|
|
if (pack.decrease == nil) then
|
|
|
|
pack.decrease = 0
|
|
|
|
end
|
|
|
|
pack.decrease = pack.decrease + resistance.decrease
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
squadHealth = squadHealth + member.max_health
|
|
|
|
squadMakeup[member.name] = squadMakeup[member.name] + 1
|
|
|
|
end
|
|
|
|
print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state, #squad.group.members, squadHealth)
|
|
|
|
print(serpent.dump(squadResistances))
|
|
|
|
print(serpent.dump(squadMakeup))
|
2016-08-20 04:52:27 +02:00
|
|
|
print(serpent.dump(squad))
|
2016-08-07 05:38:47 +02:00
|
|
|
end
|
|
|
|
end
|
2016-08-05 06:47:51 +02:00
|
|
|
end
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.entitiesOnPlayerChunk()
|
2016-08-18 07:55:08 +02:00
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
2018-05-24 02:40:05 +02:00
|
|
|
local entities = game.surfaces[global.natives.activeSurface].find_entities_filtered({area={{chunkX, chunkY},
|
2017-05-08 08:56:11 +02:00
|
|
|
{chunkX + constants.CHUNK_SIZE, chunkY + constants.CHUNK_SIZE}},
|
2016-08-18 07:55:08 +02:00
|
|
|
force="player"})
|
|
|
|
for i=1, #entities do
|
|
|
|
print(entities[i].name)
|
|
|
|
end
|
|
|
|
print("--")
|
|
|
|
end
|
2016-08-03 17:54:21 +02:00
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.findNearestPlayerEnemy()
|
2016-08-19 00:14:40 +02:00
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
2018-05-24 02:40:05 +02:00
|
|
|
local entity = game.surfaces[global.natives.activeSurface].find_nearest_enemy({position={chunkX, chunkY},
|
2016-08-20 04:52:27 +02:00
|
|
|
max_distance=constants.CHUNK_SIZE,
|
|
|
|
force = "enemy"})
|
2016-08-19 00:14:40 +02:00
|
|
|
if (entity ~= nil) then
|
|
|
|
print(entity.name)
|
|
|
|
end
|
|
|
|
print("--")
|
|
|
|
end
|
|
|
|
|
2018-02-10 07:28:41 +02:00
|
|
|
function tests.morePoints(points)
|
|
|
|
global.natives.points = global.natives.points + points
|
|
|
|
end
|
|
|
|
|
2017-05-28 06:50:37 +02:00
|
|
|
function tests.getOffsetChunk(x, y)
|
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125)
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125)
|
2018-01-14 07:48:21 +02:00
|
|
|
local chunk = mapUtils.getChunkByIndex(global.map, chunkX + x, chunkY + y)
|
2017-05-28 06:50:37 +02:00
|
|
|
print(serpent.dump(chunk))
|
|
|
|
end
|
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.aiStats()
|
2016-11-04 01:51:35 +02:00
|
|
|
print(global.natives.points, game.tick, global.natives.state, global.natives.temperament, global.natives.stateTick, global.natives.temperamentTick)
|
2016-08-19 04:02:13 +02:00
|
|
|
end
|
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.fillableDirtTest()
|
2016-08-21 02:28:35 +02:00
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
2018-05-24 02:40:05 +02:00
|
|
|
game.surfaces[global.natives.activeSurface].set_tiles({{name="fillableDirt", position={chunkX-1, chunkY-1}},
|
2017-05-08 08:56:11 +02:00
|
|
|
{name="fillableDirt", position={chunkX, chunkY-1}},
|
|
|
|
{name="fillableDirt", position={chunkX-1, chunkY}},
|
|
|
|
{name="fillableDirt", position={chunkX, chunkY}}},
|
|
|
|
false)
|
2016-08-21 02:28:35 +02:00
|
|
|
end
|
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.tunnelTest()
|
2016-08-21 02:28:35 +02:00
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
2018-05-24 02:40:05 +02:00
|
|
|
game.surfaces[global.natives.activeSurface].create_entity({name="tunnel-entrance-rampant", position={chunkX, chunkY}})
|
2016-08-21 02:28:35 +02:00
|
|
|
end
|
|
|
|
|
2017-12-21 05:50:36 +02:00
|
|
|
function tests.createEnemy(x,d)
|
2016-08-21 02:28:35 +02:00
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
2018-01-24 08:02:06 +02:00
|
|
|
local a = {name=x, position={chunkX, chunkY}, force="enemy"}
|
2017-12-21 05:50:36 +02:00
|
|
|
if d then
|
|
|
|
a['direction'] = d
|
|
|
|
end
|
2018-05-24 02:40:05 +02:00
|
|
|
return game.surfaces[global.natives.activeSurface].create_entity(a)
|
2017-05-28 06:50:37 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function tests.registeredNest(x)
|
|
|
|
local entity = tests.createEnemy(x)
|
2018-01-14 07:48:21 +02:00
|
|
|
chunk.registerEnemyBaseStructure(global.map,
|
2017-11-27 00:10:56 +02:00
|
|
|
entity,
|
|
|
|
nil)
|
2017-05-08 08:56:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function tests.attackOrigin()
|
2018-05-24 02:40:05 +02:00
|
|
|
local enemy = game.surfaces[global.natives.activeSurface].find_nearest_enemy({position={0,0},
|
2016-08-26 00:20:06 +02:00
|
|
|
max_distance = 1000})
|
|
|
|
if (enemy ~= nil) and enemy.valid then
|
|
|
|
print(enemy, enemy.unit_number)
|
|
|
|
enemy.set_command({type=defines.command.attack_area,
|
|
|
|
destination={0,0},
|
|
|
|
radius=32})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-01 06:01:28 +02:00
|
|
|
function tests.dumpNatives()
|
|
|
|
print(serpent.dump(global.natives))
|
|
|
|
end
|
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.cheatMode()
|
2016-08-27 08:44:17 +02:00
|
|
|
game.players[1].cheat_mode = true
|
|
|
|
game.forces.player.research_all_technologies()
|
|
|
|
end
|
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.gaussianRandomTest()
|
2016-11-04 01:51:35 +02:00
|
|
|
local result = {}
|
|
|
|
for x=0,100,1 do
|
|
|
|
result[x] = 0
|
|
|
|
end
|
|
|
|
for _=1,10000 do
|
2017-06-09 07:18:59 +02:00
|
|
|
local s = mathUtils.roundToNearest(mathUtils.gaussianRandomRange(50, 25, 0, 100), 1)
|
2016-11-04 01:51:35 +02:00
|
|
|
result[s] = result[s] + 1
|
|
|
|
end
|
|
|
|
for x=0,100,1 do
|
|
|
|
print(x, result[x])
|
|
|
|
end
|
2016-08-29 02:05:28 +02:00
|
|
|
end
|
|
|
|
|
2017-05-08 08:56:11 +02:00
|
|
|
function tests.reveal (size)
|
|
|
|
game.player.force.chart(game.player.surface,
|
|
|
|
{{x=-size, y=-size}, {x=size, y=size}})
|
|
|
|
end
|
|
|
|
|
|
|
|
function tests.baseStats()
|
|
|
|
local natives = global.natives
|
2017-05-19 09:47:24 +02:00
|
|
|
print ("cX", "cY", "pX", "pY", "created", "align", "str", "upgradePoints", "#nest", "#worms", "#eggs", "hive")
|
2017-05-08 08:56:11 +02:00
|
|
|
for i=1, #natives.bases do
|
|
|
|
local base = natives.bases[i]
|
2017-05-19 09:47:24 +02:00
|
|
|
local nestCount = 0
|
|
|
|
local wormCount = 0
|
|
|
|
local eggCount = 0
|
2017-06-09 07:18:59 +02:00
|
|
|
local hiveCount = 0
|
2017-05-19 09:47:24 +02:00
|
|
|
for _,_ in pairs(base.nests) do
|
|
|
|
nestCount = nestCount + 1
|
|
|
|
end
|
|
|
|
for _,_ in pairs(base.worms) do
|
|
|
|
wormCount = wormCount + 1
|
|
|
|
end
|
|
|
|
for _,_ in pairs(base.eggs) do
|
|
|
|
eggCount = eggCount + 1
|
|
|
|
end
|
2017-06-09 07:18:59 +02:00
|
|
|
for _,_ in pairs(base.hives) do
|
|
|
|
hiveCount = hiveCount + 1
|
|
|
|
end
|
|
|
|
print(base.x, base.y, base.created, base.alignment, base.strength, base.upgradePoints, nestCount, wormCount, eggCount, hiveCount)
|
|
|
|
print(serpent.dump(base.tendrils))
|
|
|
|
print("---")
|
2017-05-08 08:56:11 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function tests.clearBases()
|
|
|
|
|
2018-05-24 02:40:05 +02:00
|
|
|
local surface = game.surfaces[global.natives.activeSurface]
|
2017-05-08 08:56:11 +02:00
|
|
|
for x=#global.natives.bases,1,-1 do
|
|
|
|
local base = global.natives.bases[x]
|
|
|
|
for c=1,#base.chunks do
|
|
|
|
local chunk = base.chunks[c]
|
2017-05-12 06:50:06 +02:00
|
|
|
chunkUtils.clearChunkNests(chunk, surface)
|
2017-05-08 08:56:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
base.chunks = {}
|
|
|
|
|
2017-05-12 06:50:06 +02:00
|
|
|
if (surface.can_place_entity({name="biter-spawner-powered", position={base.cX * 32, base.cY * 32}})) then
|
|
|
|
surface.create_entity({name="biter-spawner-powered", position={base.cX * 32, base.cY * 32}})
|
2017-05-08 08:56:11 +02:00
|
|
|
local slice = math.pi / 12
|
|
|
|
local pos = 0
|
|
|
|
for i=1,24 do
|
2017-05-12 06:50:06 +02:00
|
|
|
if (math.random() < 0.8) then
|
|
|
|
local distance = mathUtils.roundToNearest(mathUtils.gaussianRandomRange(45, 5, 37, 60), 1)
|
|
|
|
if (surface.can_place_entity({name="biter-spawner", position={base.cX * 32 + (distance*math.sin(pos)), base.cY * 32 + (distance*math.cos(pos))}})) then
|
|
|
|
if (math.random() < 0.3) then
|
|
|
|
surface.create_entity({name="small-worm-turret", position={base.cX * 32 + (distance*math.sin(pos)), base.cY * 32 + (distance*math.cos(pos))}})
|
|
|
|
else
|
|
|
|
surface.create_entity({name="biter-spawner", position={base.cX * 32 + (distance*math.sin(pos)), base.cY * 32 + (distance*math.cos(pos))}})
|
|
|
|
end
|
|
|
|
end
|
2017-05-08 08:56:11 +02:00
|
|
|
end
|
|
|
|
pos = pos + slice
|
|
|
|
end
|
|
|
|
else
|
|
|
|
table.remove(global.natives.bases, x)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function tests.mergeBases()
|
|
|
|
local natives = global.natives
|
|
|
|
baseUtils.mergeBases(natives)
|
|
|
|
end
|
|
|
|
|
2018-02-17 03:44:19 +02:00
|
|
|
function tests.unitBuildBase()
|
|
|
|
end
|
|
|
|
|
2018-01-16 09:21:12 +02:00
|
|
|
function tests.showBaseGrid()
|
|
|
|
local n = {}
|
|
|
|
|
|
|
|
for k,v in pairs(global.natives.bases) do
|
2018-01-29 03:51:24 +02:00
|
|
|
n[v] = k % 4
|
2018-01-16 09:21:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local chunks = global.map.chunkToBase
|
|
|
|
for chunk,base in pairs(chunks) do
|
|
|
|
local pick = n[base]
|
|
|
|
local color = "concrete"
|
2018-01-29 03:51:24 +02:00
|
|
|
if base.alignment == constants.BASE_ALIGNMENT_NE then
|
2018-01-16 09:21:12 +02:00
|
|
|
color = "hazard-concrete-left"
|
2018-01-29 03:51:24 +02:00
|
|
|
elseif (pick == 1) then
|
|
|
|
color = "water"
|
2018-01-16 09:21:12 +02:00
|
|
|
elseif (pick == 2) then
|
|
|
|
color = "deepwater"
|
|
|
|
elseif (pick == 3) then
|
|
|
|
color = "water-green"
|
|
|
|
end
|
2018-05-24 02:40:05 +02:00
|
|
|
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[global.natives.activeSurface])
|
2018-01-16 09:21:12 +02:00
|
|
|
end
|
|
|
|
end
|
2017-12-31 21:36:23 +02:00
|
|
|
|
|
|
|
function tests.showMovementGrid()
|
2018-01-14 07:48:21 +02:00
|
|
|
local chunks = global.map.processQueue
|
2017-12-31 21:36:23 +02:00
|
|
|
for i=1,#chunks do
|
|
|
|
local chunk = chunks[i]
|
|
|
|
local color = "concrete"
|
|
|
|
if (chunk[constants.PASSABLE] == constants.CHUNK_ALL_DIRECTIONS) then
|
|
|
|
color = "hazard-concrete-left"
|
|
|
|
elseif (chunk[constants.PASSABLE] == constants.CHUNK_NORTH_SOUTH) then
|
|
|
|
color = "deepwater"
|
|
|
|
elseif (chunk[constants.PASSABLE] == constants.CHUNK_EAST_WEST) then
|
|
|
|
color = "water-green"
|
|
|
|
end
|
2018-05-24 02:40:05 +02:00
|
|
|
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[global.natives.activeSurface])
|
2017-12-31 21:36:23 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function tests.colorResourcePoints()
|
2018-01-14 07:48:21 +02:00
|
|
|
local chunks = global.map.processQueue
|
2017-12-31 21:36:23 +02:00
|
|
|
for i=1,#chunks do
|
|
|
|
local chunk = chunks[i]
|
|
|
|
local color = "concrete"
|
|
|
|
if (chunk[constants.RESOURCE_GENERATOR] ~= 0) and (chunk[constants.NEST_COUNT] ~= 0) then
|
|
|
|
color = "hazard-concrete-left"
|
|
|
|
elseif (chunk[constants.RESOURCE_GENERATOR] ~= 0) then
|
|
|
|
color = "deepwater"
|
|
|
|
elseif (chunk[constants.NEST_COUNT] ~= 0) then
|
|
|
|
color = "water-green"
|
|
|
|
end
|
2018-05-24 02:40:05 +02:00
|
|
|
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[global.natives.activeSurface])
|
2017-12-31 21:36:23 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-16 09:21:12 +02:00
|
|
|
function tests.entityStats(name, d)
|
|
|
|
local playerPosition = game.players[1].position
|
|
|
|
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
|
|
|
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
2018-05-24 02:40:05 +02:00
|
|
|
local a = game.surfaces[global.natives.activeSurface].create_entity({name=name, position={chunkX, chunkY}})
|
2018-01-16 09:21:12 +02:00
|
|
|
if d then
|
|
|
|
a['direction'] = d
|
|
|
|
end
|
|
|
|
print(serpent.dump(a))
|
|
|
|
a.destroy()
|
|
|
|
end
|
2018-01-01 07:49:36 +02:00
|
|
|
|
2018-02-19 02:21:18 +02:00
|
|
|
function tests.exportAiState()
|
2018-01-01 07:49:36 +02:00
|
|
|
|
|
|
|
local printState = function ()
|
2018-01-14 07:48:21 +02:00
|
|
|
local chunks = global.map.processQueue
|
2018-01-01 07:49:36 +02:00
|
|
|
local s = ""
|
|
|
|
for i=1,#chunks do
|
|
|
|
local chunk = chunks[i]
|
|
|
|
|
|
|
|
s = s .. table.concat({chunk[constants.MOVEMENT_PHEROMONE],
|
|
|
|
chunk[constants.BASE_PHEROMONE],
|
|
|
|
chunk[constants.PLAYER_PHEROMONE],
|
|
|
|
chunk[constants.RESOURCE_PHEROMONE],
|
|
|
|
chunk[constants.PASSABLE],
|
|
|
|
chunk[constants.CHUNK_TICK],
|
|
|
|
chunk[constants.PATH_RATING],
|
|
|
|
chunk.x,
|
|
|
|
chunk.y,
|
2018-02-01 06:01:28 +02:00
|
|
|
chunkPropertyUtils.getNestCount(global.map, chunk),
|
|
|
|
chunkPropertyUtils.getWormCount(global.map, chunk),
|
|
|
|
chunkPropertyUtils.getRallyTick(global.map, chunk),
|
|
|
|
chunkPropertyUtils.getRetreatTick(global.map, chunk),
|
|
|
|
chunkPropertyUtils.getResourceGenerator(global.map, chunk),
|
|
|
|
chunkPropertyUtils.getPlayerBaseGenerator(global.map, chunk)}, ",") .. "\n"
|
2018-01-01 07:49:36 +02:00
|
|
|
end
|
|
|
|
game.write_file("rampantState.txt", s, false)
|
|
|
|
end
|
|
|
|
|
|
|
|
return function(interval)
|
|
|
|
if not interval then
|
|
|
|
interval = 0
|
|
|
|
else
|
|
|
|
interval = tonumber(interval)
|
|
|
|
end
|
|
|
|
|
|
|
|
printState()
|
|
|
|
|
|
|
|
if (interval > 0) then
|
2018-02-19 02:21:18 +02:00
|
|
|
script.on_nth_tick(interval, printState)
|
2018-01-01 07:49:36 +02:00
|
|
|
end
|
2017-06-09 07:18:59 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-17 05:31:29 +02:00
|
|
|
function tests.unitGroupBuild()
|
2018-05-24 02:40:05 +02:00
|
|
|
local surface = game.surfaces[global.natives.activeSurface]
|
2018-02-17 05:31:29 +02:00
|
|
|
local group = surface.create_unit_group({position={-32, -32}})
|
|
|
|
|
|
|
|
for i=1,10 do
|
|
|
|
group.add_member(surface.create_entity({name="small-biter", position={-32, -32}}))
|
|
|
|
end
|
|
|
|
|
|
|
|
group.set_command({
|
|
|
|
type = defines.command.build_base,
|
|
|
|
destination = {-64, -64},
|
|
|
|
distraction = defines.distraction.by_enemy,
|
|
|
|
ignore_planner = true
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2018-02-01 06:01:28 +02:00
|
|
|
function tests.dumpEnvironment(x)
|
|
|
|
print (serpent.dump(global[x]))
|
|
|
|
end
|
|
|
|
|
2017-06-09 07:18:59 +02:00
|
|
|
function tests.stepAdvanceTendrils()
|
2017-11-21 09:27:03 +02:00
|
|
|
-- for _, base in pairs(global.natives.bases) do
|
2018-05-24 02:40:05 +02:00
|
|
|
-- tendrilUtils.advanceTendrils(global.map, base, game.surfaces[global.natives.activeSurface], {nil,nil,nil,nil,nil,nil,nil,nil})
|
2017-11-21 09:27:03 +02:00
|
|
|
-- end
|
2017-05-08 08:56:11 +02:00
|
|
|
end
|
2016-11-04 01:51:35 +02:00
|
|
|
|
2016-10-15 02:00:18 +02:00
|
|
|
return tests
|