Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility AI - framework and Editor [wip] #6323

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ae780eb
feat: removed a bunch of little warnings from princess
Scoppio Dec 21, 2024
a7bac36
feat: basis for AI editor, decision, dse, etc
Scoppio Dec 25, 2024
c6a6b76
feat: curve graph working, multi hover graph working, AI editor halfw…
Scoppio Dec 25, 2024
e87f6a1
feat: i18n the forms
Scoppio Dec 27, 2024
7c7720f
Merge branch 'MegaMek:master' into feat/tinkering-princess-ai
Scoppio Dec 27, 2024
cfa0b8b
feat: improving on the AI Editor, adding feedback on the JTree, tabs,…
Scoppio Dec 28, 2024
f842289
feat: small improvements on a couple of forms
Scoppio Dec 28, 2024
9a6966c
Merge branch 'MegaMek:master' into feat/tinkering-princess-ai
Scoppio Dec 28, 2024
c47fb96
feat: added common menu bar, removed trash code
Scoppio Dec 28, 2024
268be6f
feat: AI Editor is half-way there
Scoppio Dec 29, 2024
6771ceb
chore: update user data readme
Scoppio Dec 29, 2024
b4f5231
fix: more random profile id
Scoppio Dec 29, 2024
572a2a2
feat: added new curves, added reflection based ui controls
Scoppio Dec 30, 2024
c945812
Merge branch 'MegaMek:master' into feat/tinkering-princess-ai
Scoppio Dec 31, 2024
ae16e42
feat: import and export ai files
Scoppio Dec 31, 2024
448b792
feat: small improvements on internationalization
Scoppio Dec 31, 2024
f4fc0da
fix: fixed error where property k would show up twice for the deseria…
Scoppio Jan 1, 2025
fd167b6
Merge branch 'master' into feat/tinkering-princess-ai
Scoppio Jan 2, 2025
6454c6d
feat: adding toolbar to DSE and Profile
Scoppio Jan 2, 2025
ae60c50
Merge branch 'master' into feat/tinkering-princess-ai
Scoppio Jan 8, 2025
fc8bb3f
Merge branch 'master' into feat/tinkering-princess-ai
Scoppio Jan 9, 2025
6778e1b
chore: removing comments that borked javadoc
Scoppio Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/megamek/.intellijPlatform
/tmp/
/.metadata
/.recommenders/
Expand Down
8 changes: 7 additions & 1 deletion megamek/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ plugins {
id 'jacoco'
id 'java'
id 'org.ec4j.editorconfig' version '0.1.0'

}

java {
Expand All @@ -36,7 +35,14 @@ sourceSets {
}
}

repositories {
mavenCentral()
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
maven { url "https://jetbrains.bintray.com/intellij-third-party-dependencies" }
}

dependencies {
implementation 'com.jetbrains.intellij.java:java-gui-forms-rt:243.22562.242'
implementation 'com.fasterxml.jackson.core:jackson-core:2.17.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.2'
implementation 'com.formdev:flatlaf:3.5.1'
Expand Down
14 changes: 14 additions & 0 deletions megamek/data/ai/tw/considerations/proto_considerations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- !<MyUnitArmor>
name: "MyUnitArmor"
curve: !<LinearCurve>
m: 0.5
b: 0.3
parameters: {}
--- !<TargetWithinOptimalRange>
name: "TargetWithinOptimalRange"
curve: !<LogisticCurve>
m: 1.0
b: 0.5
k: 10.0
c: 0.0
parameters: {}
24 changes: 24 additions & 0 deletions megamek/data/ai/tw/decisions/proto_decisions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
!<TWDecision>
action: AttackUnit
weight: 1.0
decisionScoreEvaluator: !<TWDecisionScoreEvaluator>
name: "AttackEnemyInRange"
description: "Evaluate if the enemy is optimal for attack."
notes: "File for testing the load of the evaluator system."
weight: 2.5
considerations:
- !<MyUnitArmor>
name: "MyUnitArmor"
curve: !<LinearCurve>
m: 0.5
b: 0.3
parameters: {}
- !<TargetWithinOptimalRange>
name: "TargetWithinOptimalRange"
curve: !<LogisticCurve>
m: 1.0
b: 0.5
k: 10.0
c: 0.0
parameters: {}
52 changes: 52 additions & 0 deletions megamek/data/ai/tw/evaluators/proto_dse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
!<TWDecisionScoreEvaluator>
name: "AttackEnemyInRange"
description: "Evaluate if the enemy is optimal for attack."
notes: "File for testing the load of the evaluator system."
considerations:
- !<MyUnitArmor>
name: "MyUnitArmor"
curve: !<LinearCurve>
m: 0.5
b: 0.3
parameters: {}
- !<TargetWithinOptimalRange>
name: "TargetWithinOptimalRange"
curve: !<LogisticCurve>
m: 1.0
b: 0.5
k: 10.0
c: 0.0
parameters: {}
---
!<TWDecisionScoreEvaluator>
name: "Foobar"
description: "Spam Spam"
notes: "File for testing the load of the evaluator system."
weight: 2.5
considerations:
- !<MyUnitArmor>
name: "MyUnitArmor"
curve:
curveType: "LinearCurve"
m: 0.5
b: 0.3
parameters: {}
- !<TargetWithinOptimalRange>
name: "TargetWithinOptimalRange"
curve:
curveType: "LogisticCurve"
m: 1.0
b: 0.5
k: 10.0
c: 0.0
parameters: {}
- !<TargetWithinOptimalRange>
name: "TargetWithinOptimalRange"
curve:
curveType: "LogisticCurve"
m: 1.0
b: 0.5
k: 10.0
c: 0.0
parameters: {}
Empty file.
22 changes: 22 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4326,6 +4326,7 @@ MegaMek.ScenarioDialog.otherh=Other Human
MegaMek.ScenarioDialog.bot=Princess
MegaMek.ScenarioDialog.Camo=Camo
MegaMek.SkinEditor.label=Skin Editor
MegaMek.AiEditor.label=AI Editor
MegaMek.NoCamoBtn=No Camo
MegaMek.ScenarioErrorAlert.title=Scenario Error
MegaMek.ScenarioErrorAlert.message=Only one faction can be set to 'Me'.
Expand Down Expand Up @@ -4824,7 +4825,28 @@ Bot.commands.aggression=Aggression
Bot.commands.bravery=Bravery
Bot.commands.avoid=Self-Preservation
Bot.commands.caution=Piloting Caution
aiEditor.tree.title=Princess Data

#### TacOps movement and damage descriptions
TacOps.leaping.leg_damage=leaping (leg damage)
TacOps.leaping.fall_damage=leaping (fall)

### AI Editor
CommonMenuBar.AIEditorMenu=AI Editor
CommonMenuBar.aiEditor.New=New Profile
CommonMenuBar.aiEditor.Open=Open Profile
CommonMenuBar.aiEditor.RecentProfile=Recent Profiles
CommonMenuBar.aiEditor.Save=Save Profile
CommonMenuBar.aiEditor.SaveAs=Save Profile As
CommonMenuBar.aiEditor.ReloadFromDisk=Reload Profile from Disk
CommonMenuBar.aiEditor.Undo=Undo
CommonMenuBar.aiEditor.Redo=Redo
CommonMenuBar.aiEditor.NewDecision=New Decision
CommonMenuBar.aiEditor.NewConsideration=New Consideration
CommonMenuBar.aiEditor.NewDecisionScoreEvaluator=New Decision Score Evaluator
CommonMenuBar.aiEditor.Export=Export Profile
CommonMenuBar.aiEditor.ExportConsiderations=Export Considerations
CommonMenuBar.aiEditor.ExportDSE=Export Decision Score Evaluators
CommonMenuBar.aiEditor.Import=Import Profile
CommonMenuBar.aiEditor.ImportConsiderations=Import Considerations
CommonMenuBar.aiEditor.ImportDSE=Import Decision Score Evaluators
24 changes: 24 additions & 0 deletions megamek/i18n/megamek/common/options/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1023,3 +1023,27 @@ WeaponQuirksInfo.option.misrepaired_weapon.displayableName=Misrepaired Weapon
WeaponQuirksInfo.option.misrepaired_weapon.description=+1 to hit.
WeaponQuirksInfo.option.misreplaced_weapon.displayableName=Misreplaced Weapon
WeaponQuirksInfo.option.misreplaced_weapon.description=+1 to hit.
aiEditor.profile=Profile
aiEditor.action=Action
aiEditor.weight=Weight
aiEditor.profile.name=Profile Name
AiEditor.description=Description
aiEditor.notes=Notes
aiEditor.newConsideration=New Consideration
aiEditor.newDecision=New Decision
aiEditor.curve=Curve
aiEditor.name=Name
aiEditor.type=Type
aiEditor.hide=Hide
aiEditor.show=Show
aiEditor.parameters=Parameters
aiEditor.new.parameter=New Parameter
aiEditor.curve.type=Type
aiEditor.considerations=Considerations
aiEditor.description=Description
aiEditor.considerationType=Consideration
aiEditor.tab.dse=Decision Score Evaluator
aiEditor.tab.decision=Decision
aiEditor.tab.consideration=Consideration
aiEditor.tree.title=Princess Data
aiEditor.tab.dse=Decision Score Evaluator
21 changes: 21 additions & 0 deletions megamek/i18n/megamek/common/options/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,24 @@ PilotOptionsInfo.option.edge_when_explosion.displayableName= Edge für Explosi
PilotOptionsInfo.option.edge_when_explosion.description=Kritische Treffer bei explosiven Ausrüstungen werden erneut gewürfelt.
PilotOptionsInfo.option.edge_when_masc_fails.displayableName= Edge für MASC/Supercharger Ausfälle.
PilotOptionsInfo.option.edge_when_masc_fails.description=MASC/Supercharger Ausfälle werden mit Edge nachgewalzt
aiEditor.profile=Profile
aiEditor.action=Action
aiEditor.weight=Weight
aiEditor.profile.name=Profile Name
AiEditor.description=Description
aiEditor.notes=Notes
aiEditor.newConsideration=New Consideration
aiEditor.newDecision=New Decision
aiEditor.curve=Curve:
aiEditor.name=Name:
aiEditor.type=Type:
aiEditor.hide=Hide
aiEditor.show=Show
aiEditor.parameters=Parameters:
aiEditor.new.parameter=New Parameter
aiEditor.curve.type=Type
aiEditor.considerations=Considerations
aiEditor.description=Description:
aiEditor.tab.considerations=Considerations
aiEditor.tab.decision=Decision
aiEditor.tab.consideration=Consideration
20 changes: 20 additions & 0 deletions megamek/i18n/megamek/common/options/messages_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
aiEditor.action=Action
aiEditor.considerations=Considerations
aiEditor.curve=Curve:
aiEditor.curve.type=Type
AiEditor.description=Description
aiEditor.description=Description:
aiEditor.hide=Hide
aiEditor.name=Name:
aiEditor.new.parameter=New Parameter
aiEditor.newConsideration=New Consideration
aiEditor.newDecision=New Decision
aiEditor.notes=Notes
aiEditor.parameters=Parameters:
aiEditor.profile=Profile
aiEditor.profile.name=Profile Name
aiEditor.show=Show
aiEditor.tab.consideration=Consideration
aiEditor.tab.decision=Decision
aiEditor.type=Type:
aiEditor.weight=Weight
21 changes: 21 additions & 0 deletions megamek/i18n/megamek/common/options/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -986,3 +986,24 @@ WeaponQuirksInfo.option.misrepaired_weapon.displayableName=Arma mal reparada
WeaponQuirksInfo.option.misrepaired_weapon.description=+1 al golpe.
WeaponQuirksInfo.option.misreplaced_weapon.displayableName=Arma mal reemplazada
WeaponQuirksInfo.option.misreplaced_weapon.description=+1 al golpe.
aiEditor.profile=Profile
aiEditor.action=Action
aiEditor.weight=Weight
aiEditor.profile.name=Profile Name
AiEditor.description=Description
aiEditor.notes=Notes
aiEditor.newConsideration=New Consideration
aiEditor.newDecision=New Decision
aiEditor.curve=Curve:
aiEditor.name=Name:
aiEditor.type=Type:
aiEditor.hide=Hide
aiEditor.show=Show
aiEditor.parameters=Parameters:
aiEditor.new.parameter=New Parameter
aiEditor.curve.type=Type
aiEditor.considerations=Considerations
aiEditor.description=Description:
aiEditor.tab.considerations=Considerations
aiEditor.tab.decision=Decision
aiEditor.tab.consideration=Consideration
21 changes: 21 additions & 0 deletions megamek/i18n/megamek/common/options/messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -779,3 +779,24 @@ WeaponQuirksInfo.option.static_feed.displayableName=Статичное пита
WeaponQuirksInfo.option.static_feed.description=Нет игрового эффекта.\nЕще не имплементировано. (RS NTNU 3145 стр 15)
WeaponQuirksInfo.option.non_functional.displayableName=Нефункционально
WeaponQuirksInfo.option.non_functional.description=Нет игрового эффекта.\nЕще не имплементировано. (RS NTNU 3145 стр 14)
aiEditor.profile=Profile
aiEditor.action=Action
aiEditor.weight=Weight
aiEditor.profile.name=Profile Name
AiEditor.description=Description
aiEditor.notes=Notes
aiEditor.newConsideration=New Consideration
aiEditor.newDecision=New Decision
aiEditor.curve=Curve:
aiEditor.name=Name:
aiEditor.type=Type:
aiEditor.hide=Hide
aiEditor.show=Show
aiEditor.parameters=Parameters:
aiEditor.new.parameter=New Parameter
aiEditor.curve.type=Type
aiEditor.considerations=Considerations
aiEditor.description=Description:
aiEditor.tab.considerations=Considerations
aiEditor.tab.decision=Decision
aiEditor.tab.consideration=Consideration
5 changes: 5 additions & 0 deletions megamek/src/megamek/MegaMek.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public class MegaMek {
private static final MMLogger logger = MMLogger.create(MegaMek.class);
private static final SanityInputFilter sanityInputFilter = new SanityInputFilter();

public static boolean isDevelopment() {
// env variable mm.profile=dev
return "dev".equals(System.getenv("mm.profile"));
}

public static void main(String... args) {
ObjectInputFilter.Config.setSerialFilter(sanityInputFilter);

Expand Down
34 changes: 34 additions & 0 deletions megamek/src/megamek/ai/utility/Action.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
*/

package megamek.ai.utility;

public enum Action {

AttackUnit("Attack Unit"),
MoveToPosition("Move to Position"),
IndirectAttack("Indirect Attack"),
UseSpecialAbility("Use Special Ability");

private final String actionName;

Action(String actionName) {
this.actionName = actionName;
}

public String getActionName() {
return actionName;
}
}
24 changes: 24 additions & 0 deletions megamek/src/megamek/ai/utility/Agent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

package megamek.ai.utility;

import megamek.client.IClient;

public interface Agent <IN_GAME_OBJECT, TARGETABLE> {
int getId();
World<IN_GAME_OBJECT, TARGETABLE> getContext();
Intelligence<IN_GAME_OBJECT, TARGETABLE> getIntelligence();
IClient getClient();
}
Loading
Loading