Changeset 10043
- Timestamp:
- 10/16/13 15:47:25 (11 years ago)
- Location:
- branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/EnemyCollection.cs
r10011 r10043 33 33 [StorableClass] 34 34 public class EnemyCollection : CheckedItemList<StringValue> { 35 private const string sampleRobotToSelect = "sample.Crazy"; 36 35 37 [Storable] 36 38 public string RobocodePath { get; set; } … … 69 71 robotList.SetItemCheckedState(robot, false); 70 72 } 71 } catch { } 73 } 74 catch { } 75 76 //select one robot so that if a user tries out the Robocode problem it works with the default settings 77 if (robotList.Exists(x => x.Value == sampleRobotToSelect)) { 78 StringValue sampleRobot = robotList.Single(x => x.Value == sampleRobotToSelect); 79 robotList.SetItemCheckedState(sampleRobot, true); 80 } 72 81 73 82 return robotList; -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Grammar.cs
r10028 r10043 20 20 #endregion 21 21 22 using System.Linq;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 34 33 private const string ControlStatementsName = "Control Statements"; 35 34 private const string RobocodeFunctionsName = "Robocode Functions"; 35 private const string RobocodeActionsName = "Robocode Actions"; 36 36 private const string RelationalOperatorsName = "Relational Operators"; 37 37 private const string LogicalOperators = "Logical Operators"; … … 94 94 var getY = new GetY(); 95 95 96 //var setAdjustGunForRobotTurn = new SetAdjustGunForRobotTurn();97 //var setAdjustRadarForGunTurn = new SetAdjustRadarForGunTurn();98 //var setAdjustRadarForRobotTurn = new SetAdjustRadarForRobotTurn();99 //var independent = new Independent();100 101 96 var turnLeft = new TurnLeft(); 102 97 var turnRight = new TurnRight(); … … 124 119 var actionSymbols = new ISymbol[] { 125 120 ahead, back, fire, turnGunLeft, turnGunRight, turnLeft, turnRadarLeft, turnRadarRight, turnRight 126 //setAdjustGunForRobotTurn, setAdjustRadarForGunTurn, setAdjustRadarForRobotTurn,127 121 }; 128 122 var functionSymbols = new ISymbol[] { … … 130 124 }; 131 125 132 var events = new GroupSymbol(EventsName, new ISymbol[] { onScannedRobot, onBulletHit, onBulletMissed, onHitByBullet, onHitRobot, onHitWall });126 var events = new GroupSymbol(EventsName, new ISymbol[] { run, onScannedRobot, onBulletHit, onBulletMissed, onHitByBullet, onHitRobot, onHitWall }); 133 127 var controlStatements = new GroupSymbol(ControlStatementsName, controlSymbols); 134 128 var expressions = new GroupSymbol(ExpressionsName, new ISymbol[] { logicalExpr, numericalExpr }); 135 var robocodeFunctions = new GroupSymbol(RobocodeFunctionsName, actionSymbols.Concat(functionSymbols)); 129 var robocodeFunctions = new GroupSymbol(RobocodeFunctionsName, functionSymbols); 130 var robocodeActions = new GroupSymbol(RobocodeActionsName, actionSymbols); 136 131 var relationalOperators = new GroupSymbol(RelationalOperatorsName, new ISymbol[] { equal, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual }); 137 132 var logicalOperators = new GroupSymbol(LogicalOperators, new ISymbol[] { conjunction, disjunction, negation }); … … 141 136 #region Adding Symbols 142 137 AddSymbol(tank); 143 AddSymbol(run);144 138 AddSymbol(stat); 145 139 AddSymbol(block); … … 151 145 AddSymbol(controlStatements); 152 146 AddSymbol(robocodeFunctions); 147 AddSymbol(robocodeActions); 153 148 AddSymbol(relationalOperators); 154 149 AddSymbol(logicalOperators); … … 171 166 AddAllowedChildSymbol(tank, onHitWall, 6); 172 167 173 // Run 174 AddAllowedChildSymbol(run, stat); 175 176 // Event 177 foreach (var s in events.Symbols) 178 AddAllowedChildSymbol(s, stat); 168 // Events 169 AddAllowedChildSymbol(events, stat); 179 170 180 171 // Block … … 184 175 AddAllowedChildSymbol(stat, stat); 185 176 AddAllowedChildSymbol(stat, block); 186 foreach (var s in controlSymbols) 187 AddAllowedChildSymbol(stat, s); 188 foreach (var s in robocodeFunctions.Symbols) 189 AddAllowedChildSymbol(stat, s); 177 AddAllowedChildSymbol(stat, controlStatements); 178 AddAllowedChildSymbol(stat, robocodeFunctions); 179 AddAllowedChildSymbol(stat, robocodeActions); 190 180 AddAllowedChildSymbol(stat, emptyEvent); 191 181 AddAllowedChildSymbol(stat, doNothing); … … 207 197 208 198 // Numerical Expressions 209 foreach (var s in functionSymbols.Concat(new[] { number })) 210 AddAllowedChildSymbol(numericalExpr, s); 211 foreach (var s in numericalOperators.Symbols) { 212 AddAllowedChildSymbol(numericalExpr, s); 213 foreach (var ne in functionSymbols.Concat(new[] { number })) 214 AddAllowedChildSymbol(s, ne); 215 foreach (var no in numericalOperators.Symbols) { 216 AddAllowedChildSymbol(s, no); 217 } 218 } 199 AddAllowedChildSymbol(numericalExpr, number); 200 AddAllowedChildSymbol(numericalExpr, robocodeFunctions); 201 AddAllowedChildSymbol(numericalExpr, numericalOperators); 202 AddAllowedChildSymbol(numericalOperators, number); 203 AddAllowedChildSymbol(numericalOperators, robocodeFunctions); 204 AddAllowedChildSymbol(numericalOperators, numericalOperators); 219 205 220 206 // Logical Expressions 221 207 AddAllowedChildSymbol(logicalExpr, logicalVal); 222 foreach (var s in logicalOperators.Symbols) { 223 AddAllowedChildSymbol(logicalExpr, s); 224 AddAllowedChildSymbol(s, logicalVal); 225 foreach (var lo in logicalOperators.Symbols) 226 AddAllowedChildSymbol(s, lo); 227 foreach (var ro in relationalOperators.Symbols) 228 AddAllowedChildSymbol(s, ro); 229 } 230 foreach (var s in relationalOperators.Symbols) 231 AddAllowedChildSymbol(s, numericalExpr); 232 233 // Functions 234 foreach (var f in robocodeFunctions.Symbols) { 235 if (f is Fire) AddAllowedChildSymbol(f, shotPower); 236 else AddAllowedChildSymbol(f, numericalExpr); 208 AddAllowedChildSymbol(logicalExpr, logicalOperators); 209 AddAllowedChildSymbol(logicalOperators, logicalVal); 210 AddAllowedChildSymbol(logicalOperators, logicalOperators); 211 AddAllowedChildSymbol(logicalOperators, relationalOperators); 212 AddAllowedChildSymbol(relationalOperators, numericalExpr); 213 214 // Functions and Actions 215 AddAllowedChildSymbol(robocodeFunctions, numericalExpr); 216 foreach (var a in robocodeActions.Symbols) { 217 if (a is Fire) AddAllowedChildSymbol(a, shotPower); 218 else AddAllowedChildSymbol(a, numericalExpr); 237 219 } 238 220 #endregion -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/RobocodeProblem.cs
r10014 r10043 87 87 Parameters.Add(new ValueParameter<Grammar>(TankGrammarParameterName, "Grammar for the tank program.", new Grammar())); 88 88 Parameters.Add(new FixedValueParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.", robocodeDir)); 89 Parameters.Add(new FixedValueParameter<IntValue>(NrOfRoundsParameterName, "Nr. of Rounds a Robot has to fight against each opponent.", new IntValue(3)));89 Parameters.Add(new FixedValueParameter<IntValue>(NrOfRoundsParameterName, "Nr. of rounds a robot has to fight against each opponent.", new IntValue(3))); 90 90 Parameters.Add(new ValueParameter<EnemyCollection>(EnemiesParameterName, "The enemies that should be battled.", robotList)); 91 91 -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Solution.cs
r9971 r10043 27 27 namespace HeuristicLab.Problems.Robocode { 28 28 [StorableClass] 29 [Item("Solution", " A Robocode program.")]29 [Item("Solution", "Robocode program and configuration.")] 30 30 public sealed class Solution : Item { 31 31 [Storable] -
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Statements/IfThenElseStat.cs
r10028 r10043 50 50 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 51 51 ISymbolicExpressionTreeNode condition = null, truePart = null, falsePart = null; 52 string[] parts = new string[3]; 52 53 var enumerator = children.GetEnumerator(); 53 54 int childCount = 0; … … 63 64 if (childCount < 2) throw new ArgumentException("Unexpected number of children. Expected at least 2 children."); 64 65 65 var parts = new[] { 66 ((CodeNode)condition.Symbol).Interpret(condition, condition.Subtrees), 67 ((CodeNode)truePart.Symbol).Interpret(truePart, truePart.Subtrees), 68 ((CodeNode)falsePart.Symbol).Interpret(falsePart, falsePart.Subtrees) 69 }; 66 parts[0] = ((CodeNode)condition.Symbol).Interpret(condition, condition.Subtrees); 67 parts[1] = ((CodeNode)truePart.Symbol).Interpret(truePart, truePart.Subtrees); 68 if (childCount == 3) parts[2] = ((CodeNode)falsePart.Symbol).Interpret(falsePart, falsePart.Subtrees); 70 69 71 70 string result = "if (" + parts[0] + ") {" + parts[1] + "}";
Note: See TracChangeset
for help on using the changeset viewer.