Skip to content

Commit

Permalink
basic package validation passes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManApart committed Jan 19, 2024
1 parent b3a82c2 commit f060e1b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/core/ai/packages/AIPackageTemplate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ data class AIPackageTemplate(val name: String, val subPackages: List<String>, va
?: subPackage.flatten(reference, flattenedReference).also { flattenedReference[subPackage.name] = it }.ideas.values.flatten()
}.map { idea ->
priorityOverride[it.name]?.let { idea.copy(priority = it) } ?: idea
}
AIPackage(name, ideas + subIdeas)
}.map { it.copy(name = "$name-${it.name}")}
AIPackage(name, ideas + subIdeas).also { flattenedReference[name] = it }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package core.ai.packages

import core.thing.Thing
import core.utility.map

//Build all the templates, but don't flatten them
//Using the dependency injection, we could have many things producing the templates
Expand All @@ -16,7 +17,8 @@ class AIPackageTemplateBuilder(val name: String) {
private val priorityOverride = mutableMapOf<String, Int>()

fun build(): AIPackageTemplate {
return AIPackageTemplate(name, templates, priorityOverride, ideas.map { it.build(name) })
val childIdeas = criteriaChildren.flatMap { (parentCriteria, builder) -> builder.getChildren(parentCriteria) }
return AIPackageTemplate(name, templates, priorityOverride, (ideas + childIdeas).map { it.build(name) })
}

fun template(vararg names: String) = this.templates.addAll(names)
Expand All @@ -25,7 +27,7 @@ class AIPackageTemplateBuilder(val name: String) {
Override the priority of an idea inherited from a template.
*/
fun priority(ideaName: String, newPriority: Int){

priorityOverride[ideaName] = newPriority
}

fun idea(name: String, priority: Int = 20, initializer: IdeaBuilder.() -> Unit = {}) {
Expand Down
4 changes: 0 additions & 4 deletions src/commonMain/kotlin/resources/ai/packages/CommonPackages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ class CommonPackages: AIPackageTemplateResource {
criteria { !it.isSafe() }
action { EatFoodEvent(it, it) }
}
idea("wait") {
criteria { !it.isSafe() }
action { EatFoodEvent(it, it) }
}
}
}
}
Expand Down

0 comments on commit f060e1b

Please sign in to comment.