mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-15 04:15:28 +07:00
separate unique/explicit traits instead hidden
This commit is contained in:
@@ -9,3 +9,7 @@ print '----------------------------------------'
|
||||
basics.describe_fuzz 'develop.fuzzing.destroy_fuzz'
|
||||
print '----------------------------------------'
|
||||
basics.describe_fuzz 'develop.fuzzing.batch_destroy_fuzz'
|
||||
print '----------------------------------------'
|
||||
basics.describe_fuzz 'develop.fuzzing.explicit_fuzz'
|
||||
print '----------------------------------------'
|
||||
basics.describe_fuzz 'develop.fuzzing.unique_fuzz'
|
||||
|
||||
@@ -33,7 +33,7 @@ for _, entity in ipairs(all_entity_list) do
|
||||
end
|
||||
|
||||
if math.random(1, 5) == 1 then
|
||||
evo.set(entity, evo.HIDDEN)
|
||||
evo.set(entity, evo.EXPLICIT)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ for _ = 1, 100 do
|
||||
local fragment_list, fragment_count = chunk:fragments()
|
||||
for i = 1, fragment_count do
|
||||
local fragment = fragment_list[i]
|
||||
assert(include_set[fragment] or not evo.has(fragment, evo.HIDDEN))
|
||||
assert(include_set[fragment] or not evo.has(fragment, evo.EXPLICIT))
|
||||
end
|
||||
end
|
||||
|
||||
67
develop/fuzzing/unique_fuzz.lua
Normal file
67
develop/fuzzing/unique_fuzz.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
local evo = require 'evolved'
|
||||
|
||||
evo.debug_mode(true)
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
|
||||
local __table_unpack = (function()
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
return table.unpack or unpack
|
||||
end)()
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
|
||||
local all_entity_list = {} ---@type evolved.entity[]
|
||||
|
||||
for i = 1, math.random(1, 10) do
|
||||
local entity = evo.id()
|
||||
all_entity_list[i] = entity
|
||||
end
|
||||
|
||||
for _, entity in ipairs(all_entity_list) do
|
||||
for _ = 0, math.random(0, #all_entity_list) do
|
||||
local fragment = all_entity_list[math.random(1, #all_entity_list)]
|
||||
evo.set(entity, fragment)
|
||||
end
|
||||
|
||||
if math.random(1, 5) == 1 then
|
||||
evo.set(entity, evo.UNIQUE)
|
||||
end
|
||||
end
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
|
||||
for _, entity in ipairs(all_entity_list) do
|
||||
local entity_clone = evo.clone(entity)
|
||||
|
||||
for fragment in evo.each(entity_clone) do
|
||||
assert(not evo.has(fragment, evo.UNIQUE))
|
||||
end
|
||||
|
||||
for fragment in evo.each(entity) do
|
||||
assert(evo.has(entity_clone, fragment) or evo.has(fragment, evo.UNIQUE))
|
||||
end
|
||||
|
||||
evo.destroy(entity_clone)
|
||||
end
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
---
|
||||
|
||||
evo.destroy(__table_unpack(all_entity_list))
|
||||
evo.collect_garbage()
|
||||
@@ -6160,8 +6160,8 @@ end
|
||||
do
|
||||
local f1, f2, f3 = evo.id(3)
|
||||
|
||||
evo.set(f2, evo.HIDDEN)
|
||||
evo.set(f3, evo.HIDDEN)
|
||||
evo.set(f2, evo.UNIQUE)
|
||||
evo.set(f3, evo.UNIQUE)
|
||||
|
||||
do
|
||||
local p = evo.spawn { [f1] = 11, [f2] = 22 }
|
||||
@@ -6239,7 +6239,7 @@ end
|
||||
do
|
||||
local f1, f2, f3 = evo.id(3)
|
||||
|
||||
evo.set(f2, evo.HIDDEN)
|
||||
evo.set(f2, evo.UNIQUE)
|
||||
|
||||
do
|
||||
local p = evo.spawn { [f1] = 11, [f2] = 22, [f3] = 33 }
|
||||
@@ -6275,7 +6275,7 @@ do
|
||||
|
||||
for c in evo.execute(q) do
|
||||
local fs, fc = c:fragments()
|
||||
for i = 1, fc do assert(not evo.has(fs[i], evo.HIDDEN)) end
|
||||
for i = 1, fc do assert(not evo.has(fs[i], evo.EXPLICIT)) end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6284,7 +6284,7 @@ do
|
||||
|
||||
for c in evo.execute(q) do
|
||||
local fs, fc = c:fragments()
|
||||
for i = 1, fc do assert(not evo.has(fs[i], evo.HIDDEN)) end
|
||||
for i = 1, fc do assert(not evo.has(fs[i], evo.EXPLICIT)) end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6292,7 +6292,7 @@ end
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
|
||||
evo.set(f2, evo.HIDDEN)
|
||||
evo.set(f2, evo.EXPLICIT)
|
||||
|
||||
local e1 = evo.builder():set(f1, 11):spawn()
|
||||
local e2 = evo.builder():set(f1, 11):set(f2, 22):spawn()
|
||||
|
||||
Reference in New Issue
Block a user