Feature/evolution #1
+5
-5
@@ -1,7 +1,5 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
#signal produce_items(item_id: String, amount: int)
|
|
||||||
|
|
||||||
const OWNIVERSE_ITEM = preload("uid://d3xjfxwe3w16v")
|
const OWNIVERSE_ITEM = preload("uid://d3xjfxwe3w16v")
|
||||||
|
|
||||||
const SPEED_TEXTURE_NAME_TEMPLATE = "res://ui/topmenu/time&speed/time%s.png"
|
const SPEED_TEXTURE_NAME_TEMPLATE = "res://ui/topmenu/time&speed/time%s.png"
|
||||||
@@ -98,9 +96,6 @@ func set_owniverse_item_value() -> void:
|
|||||||
owniverse.items_to_update = {}
|
owniverse.items_to_update = {}
|
||||||
|
|
||||||
|
|
||||||
#func unlock_owniverse_item() -> void:
|
|
||||||
#pass
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
func _on_indicator_pressed(indicator_name: String, page: int = 0):
|
func _on_indicator_pressed(indicator_name: String, page: int = 0):
|
||||||
@@ -300,6 +295,11 @@ func _change_speed(delta: int) -> void:
|
|||||||
|
|
||||||
func _on_topmenu_button_pressed(ButtonName) -> void:
|
func _on_topmenu_button_pressed(ButtonName) -> void:
|
||||||
print(ButtonName)
|
print(ButtonName)
|
||||||
|
#var s: float = 1E15
|
||||||
|
#var z = 1.0
|
||||||
|
#for i in range(30):
|
||||||
|
#print(i, " | ", z, " | ", " | ", s - z)
|
||||||
|
#z *= 10
|
||||||
|
|
||||||
|
|
||||||
func _on_save_data() -> void:
|
func _on_save_data() -> void:
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ LRG|0||||50||50000000||||S:300||DSN^SGRB%0.1|2|||RG|Star|||||
|
|||||||
HRG|0||||100||10000000||||S:400.||SN^GRB%1|2|||RG|Star|||||
|
HRG|0||||100||10000000||||S:400.||SN^GRB%1|2|||RG|Star|||||
|
||||||
RSG|0||||300||1000000||||S:500||BSN^LGRB%3|2|||RG|Star|||||
|
RSG|0||||300||1000000||||S:500||BSN^LGRB%3|2|||RG|Star|||||
|
||||||
RHG|0||||1000||100000||||S:600||HN^HGRB%10|2|||RG|Star|||||
|
RHG|0||||1000||100000||||S:600||HN^HGRB%10|2|||RG|Star|||||
|
||||||
DSN|0||||||0|||2|S:59.1||SNS:1&H:6.5&He:13.5&Met:11&blast:2|2|mass:15&H:6.5&HE:13.5&MET:11||||SNGRBB||||
|
DSN|0||||||1|||2|S:59.1||SNS:1&H:6.5&He:13.5&Met:11&blast:2|2|mass:15&H:6.5&HE:13.5&MET:11||||SNGRBB||||
|
||||||
SN|0||||||0|||9|S:99.1||LNS:1&H:8&He:50&Met:11&blast:9|2|mass:18&H:8&HE:50&MET:11||||SNGRBB||||
|
SN|0||||||1|||9|S:99.1||LNS:1&H:8&He:50&Met:11&blast:9|2|mass:18&H:8&HE:50&MET:11||||SNGRBB||||
|
||||||
BSN|0||||||0||.|305|S:309.1||MGT:1&H:15&He:186&Met:15&blast:305|2|mass:21&H:15&HE:186&MET:15||||SNGRBB||||
|
BSN|0||||||1||.|305|S:309.1||MGT:1&H:15&He:186&Met:15&blast:305|2|mass:21&H:15&HE:186&MET:15||||SNGRBB||||
|
||||||
HN|0||||||0|||9990|S:939.1||BH40:1&H:30&He:560&Met:30&blast:9990|2|mass:40&H:30&HE:560&MET:30||||SNGRBB||||
|
HN|0||||||1|||9990|S:939.1||BH40:1&H:30&He:560&Met:30&blast:9990|2|mass:40&H:30&HE:560&MET:30||||SNGRBB||||
|
||||||
SGRB|0||||||0||0.001|31|S:149.1||BH25:1&H:0.5&He:10&Met:4&blast:31|2|mass:25&H:0.5&HE:10&MET:4||||SNGRBB||||
|
SGRB|0||||||1||0.001|31|S:149.1||BH25:1&H:0.5&He:10&Met:4&blast:31|2|mass:25&H:0.5&HE:10&MET:4||||SNGRBB||||
|
||||||
GRB|0||||||0||0.01|136|S:239.1||BH30:1&H:19&He:12&Met:5&blast:136|2|mass:30&H:19&HE:12&MET:5||||SNGRBB||||
|
GRB|0||||||1||0.01|136|S:239.1||BH30:1&H:19&He:12&Met:5&blast:136|2|mass:30&H:19&HE:12&MET:5||||SNGRBB||||
|
||||||
LGRB|0||||||0||0.03|3446|S:669.1||BH40:1&H:68&He:18&Met:9&blast:3446|2|mass:40&H:68&HE:18&MET:9||||SNGRBB||||
|
LGRB|0||||||1||0.03|3446|S:669.1||BH40:1&H:68&He:18&Met:9&blast:3446|2|mass:40&H:68&HE:18&MET:9||||SNGRBB||||
|
||||||
HGRB|0||||||0||0.1|97342|S:1939.1||BH60:1&H:0&He:40&Met:10&blast:97342|2|mass:60&H:0&HE:40&MET:10||||SNGRBB||||
|
HGRB|0||||||1||0.1|97342|S:1939.1||BH60:1&H:0&He:40&Met:10&blast:97342|2|mass:60&H:0&HE:40&MET:10||||SNGRBB||||
|
||||||
CBD|0||||0.1||||||||||||BD||||||
|
CBD|0||||0.1||||||||||||BD||||||
|
||||||
WD|1|WD:1|||||||||||||||||||||
|
WD|1|WD:1|||||||||||||||||||||
|
||||||
TWD|0||||0.8||||||||||||WD|Star|Degen||||
|
TWD|0||||0.8||||||||||||WD|Star|Degen||||
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ var evolution: OwniverseEvolution = OwniverseEvolution.new()
|
|||||||
|
|
||||||
signal unlock_item(item_id: String)
|
signal unlock_item(item_id: String)
|
||||||
|
|
||||||
var current_year: float = 0
|
var current_year: float = 0.0
|
||||||
var current_speed: int = 1
|
var current_speed: int = 1
|
||||||
var current_speed_in_years: float = 1
|
var current_speed_in_years: float = 1.0
|
||||||
|
|
||||||
var entities: Dictionary[String, OwniverseEntity] = {}
|
var entities: Dictionary[String, OwniverseEntity] = {}
|
||||||
var entity_groups: Dictionary[String, Array] = {}
|
var entity_groups: Dictionary[String, Array] = {}
|
||||||
@@ -21,24 +21,15 @@ var locked_entities: Array = []
|
|||||||
var cumulative_amount: Dictionary[String, float] = {}
|
var cumulative_amount: Dictionary[String, float] = {}
|
||||||
var current_amount: Dictionary[String, float] = {}
|
var current_amount: Dictionary[String, float] = {}
|
||||||
|
|
||||||
#var batch_count: int = 40
|
|
||||||
#var entity_batches = {}
|
|
||||||
|
|
||||||
|
|
||||||
func cycle(year_delta: float) -> void:
|
func cycle(year_delta: float) -> void:
|
||||||
# all owniverse activity should be called here
|
# all owniverse activity should be called here
|
||||||
_auto_production(year_delta)
|
_auto_production(year_delta)
|
||||||
#_entity_evolution(year_delta)
|
|
||||||
|
|
||||||
_check_locked_items()
|
_check_locked_items()
|
||||||
|
|
||||||
#var v = _get_distribution(current_amount)
|
|
||||||
evolution.update_distribution(current_amount)
|
evolution.update_distribution(current_amount)
|
||||||
|
|
||||||
#for k in current_amount:
|
|
||||||
#if current_amount[k] != 0:
|
|
||||||
#print(k, "|", current_amount[k])
|
|
||||||
|
|
||||||
|
|
||||||
#region auto production and evolution
|
#region auto production and evolution
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ var gamma: float
|
|||||||
var blast: int
|
var blast: int
|
||||||
var life_product: Dictionary = {}
|
var life_product: Dictionary = {}
|
||||||
var product_per_year_type: String = ""
|
var product_per_year_type: String = ""
|
||||||
var product_per_year_amount: float = 0.0
|
var product_per_year_amount: float = 0
|
||||||
var voids: int
|
var voids: int
|
||||||
var output_or: Dictionary = {}
|
var output_or: Dictionary = {}
|
||||||
var output_and: Dictionary = {}
|
var output_and: Dictionary = {}
|
||||||
@@ -41,14 +41,16 @@ func _init(values: Dictionary) -> void:
|
|||||||
mass = float(values.mass)
|
mass = float(values.mass)
|
||||||
space = int(values.space)
|
space = int(values.space)
|
||||||
lifespan = float(values.lifespan)
|
lifespan = float(values.lifespan)
|
||||||
lifespan_delta = lifespan / Global.batch_count / 2 # need for proper math
|
lifespan_delta = lifespan / Global.batch_count / 2 if lifespan > 10 else lifespan
|
||||||
auto = float(values.auto)
|
auto = float(values.auto)
|
||||||
gamma = float(values.gamma)
|
gamma = float(values.gamma)
|
||||||
blast = int(values.blast)
|
blast = int(values.blast)
|
||||||
|
|
||||||
life_product = _parse_and_string(values.life_product)
|
life_product = _parse_and_string(values.life_product)
|
||||||
for key in life_product.keys():
|
for key in life_product.keys():
|
||||||
product_per_year_type = key
|
product_per_year_type = key
|
||||||
product_per_year_amount = life_product[key] / lifespan if lifespan != 0 else 0
|
product_per_year_amount = life_product[key] / lifespan if lifespan != 0 else 0
|
||||||
|
#print(id, " | ", lifespan_delta, " | ", lifespan)
|
||||||
|
|
||||||
voids = int(values.voids)
|
voids = int(values.voids)
|
||||||
output_or = _parse_or_string(values.output)
|
output_or = _parse_or_string(values.output)
|
||||||
|
|||||||
@@ -2,13 +2,31 @@ extends Node
|
|||||||
|
|
||||||
class_name OwniverseEvolution
|
class_name OwniverseEvolution
|
||||||
|
|
||||||
|
const FLOAT_THRESHOLD: float = 1.0E14
|
||||||
|
# TODO to save !!!
|
||||||
|
var state: Dictionary = {
|
||||||
|
'year': 0.0,
|
||||||
|
'energy': 1E14,
|
||||||
|
}
|
||||||
|
|
||||||
var entities: Dictionary[String, OwniverseEntity] = {}
|
var entities: Dictionary[String, OwniverseEntity] = {}
|
||||||
|
|
||||||
var producing_entities: Array[OwniverseEntity] = []
|
var producing_entities: Array[OwniverseEntity] = []
|
||||||
var auto_producing_entities: Array[OwniverseEntity] = []
|
|
||||||
var auto_production_rest: Dictionary[String, float] = {}
|
# TODO to save !!!
|
||||||
|
var auto_production_rest: Dictionary = {
|
||||||
|
'H': 0.0,
|
||||||
|
'S': 0.0,
|
||||||
|
'auto': 0.0,
|
||||||
|
}
|
||||||
|
|
||||||
var evolving_entities: Array[OwniverseEntity] = []
|
var evolving_entities: Array[OwniverseEntity] = []
|
||||||
|
|
||||||
|
# TODO to save !!!
|
||||||
var batches: Dictionary[String, Array] = {}
|
var batches: Dictionary[String, Array] = {}
|
||||||
|
# TODO to save !!!
|
||||||
|
var amount: Dictionary[String, float] = {}
|
||||||
|
|
||||||
|
|
||||||
var distribution: Dictionary[String, float] = {}
|
var distribution: Dictionary[String, float] = {}
|
||||||
|
|
||||||
@@ -27,6 +45,9 @@ func add(entity: OwniverseEntity, year: float, amount: float):
|
|||||||
}
|
}
|
||||||
_batch_array.append(_batch)
|
_batch_array.append(_batch)
|
||||||
|
|
||||||
|
print('---------')
|
||||||
|
print(batches)
|
||||||
|
|
||||||
|
|
||||||
func process(from_year: float, to_year: float) -> void:
|
func process(from_year: float, to_year: float) -> void:
|
||||||
# производим
|
# производим
|
||||||
@@ -68,33 +89,42 @@ func produce(from_year: float, to_year: float):
|
|||||||
var _time_delta = to_year - from_year
|
var _time_delta = to_year - from_year
|
||||||
# get entity array for production
|
# get entity array for production
|
||||||
for _entity: OwniverseEntity in producing_entities:
|
for _entity: OwniverseEntity in producing_entities:
|
||||||
var _to_produce: float = 0
|
var _to_produce: float = 0.0
|
||||||
var _new_batch_array:= []
|
|
||||||
for _batch: Dictionary in batches[_entity.id]:
|
for _batch: Dictionary in batches[_entity.id]:
|
||||||
_to_produce += _batch.amount
|
_to_produce += _batch.amount
|
||||||
# production
|
|
||||||
_to_produce *= _time_delta * _entity.product_per_year_amount
|
_to_produce *= _time_delta * _entity.product_per_year_amount
|
||||||
var _auto_production_part: float = 0
|
|
||||||
if _entity.auto > 0:
|
if _entity.auto > 0:
|
||||||
_auto_production_part = _entity.auto * _to_produce
|
var _auto_production_part: float = _entity.auto * _to_produce
|
||||||
|
_to_produce -= _auto_production_part
|
||||||
|
auto_production_rest.auto += _auto_production_part
|
||||||
|
|
||||||
# and rest
|
auto_production_rest[_entity.product_per_year_type] += _to_produce
|
||||||
# energy = wasted vs rest !!
|
print("auto prod rest: ", auto_production_rest)
|
||||||
|
auto_production_rest["H"] = produce_hs("H", auto_production_rest["H"])
|
||||||
|
auto_production_rest["S"] = produce_hs("S", auto_production_rest["S"])
|
||||||
|
|
||||||
|
|
||||||
|
func produce_hs(entity_id: String, value: float) -> float:
|
||||||
|
var _to_produce:float = floorf(value)
|
||||||
|
amount[entity_id] += _to_produce
|
||||||
|
# TODO double double math
|
||||||
|
if _to_produce > state["energy"]:
|
||||||
|
_to_produce = state["energy"]
|
||||||
|
state["energy"] -= _to_produce
|
||||||
|
return value - _to_produce
|
||||||
|
|
||||||
|
func produce_auto() -> float:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
func init_entity(entity: OwniverseEntity) -> void:
|
func init_entity(entity: OwniverseEntity) -> void:
|
||||||
entities[entity.id] = entity
|
entities[entity.id] = entity
|
||||||
|
amount[entity.id] = 0.0
|
||||||
if entity.product_per_year_type != "":
|
if entity.product_per_year_type != "":
|
||||||
producing_entities.append(entity)
|
producing_entities.append(entity)
|
||||||
|
|
||||||
if entity.lifespan > 0:
|
if entity.lifespan > 0:
|
||||||
evolving_entities.append(entity)
|
evolving_entities.append(entity)
|
||||||
|
|
||||||
if entity.auto > 0:
|
|
||||||
auto_producing_entities.append(entity)
|
|
||||||
auto_production_rest[entity.id] = 0
|
|
||||||
|
|
||||||
batches[entity.id] = []
|
batches[entity.id] = []
|
||||||
|
|
||||||
|
|
||||||
@@ -111,3 +141,9 @@ func update_distribution(_distribute_by: Dictionary[String, float]) -> void:
|
|||||||
|
|
||||||
for id in distribution:
|
for id in distribution:
|
||||||
distribution[id] /= _total
|
distribution[id] /= _total
|
||||||
|
|
||||||
|
#func _add_float(a: float, b: Array[float]) -> Array[float]:
|
||||||
|
#if a < FLOAT_THRESHOLD:
|
||||||
|
#return [a+b[0], 0]
|
||||||
|
#else:
|
||||||
|
#return [a+b[0], 0]
|
||||||
|
|||||||
Reference in New Issue
Block a user