--- /dev/null
+#
+# matlab-consts.m
+# matlab-link
+#
+# Created by Daniel Axtens on 28/07/10.
+# Licensed under an MIT-style license: see the LICENSE file for details.
+#
+
+# A collection of useful functions and constants for use in your agent-writing.
+# Please use the symbolic values (see the sample agents) and don't use hard-coded
+# values: if we have to change how things are represented internally, for example
+# to make things run faster, we don't want to suddenly have your agent break.
+#
+# For example, use rps.rock to get a rock, don't use 1.
+
+
+# Define some constants
+# access these with rps.<whatever>, see the sample agents for examples
+
+global rps = struct (
+ "rock", 1,
+ "paper", 2,
+ "scissors", 3,
+
+ "itemToString", {{ "Rock", "Paper", "Scissors" }}
+);
+
+# Random Item/Attack
+function item = RandomAttack()
+ global rps
+
+ switch (floor(rand(1)*3))
+ case 0
+ item = rps.rock;
+ case 1
+ item = rps.paper;
+ otherwise
+ item = rps.scissors;
+ endswitch
+endfunction
+
+
+function item = stringToItem( itemString )
+ global rps;
+
+ switch itemString
+ case "Rock"
+ item = rps.rock;
+ case "Scissors"
+ item = rps.scissors;
+ case "Paper"
+ item = rps.paper;
+ otherwise
+ # this shouldn't happen; this is passed by the supervisor, not a user
+ error( "tried to convert invalid string into Rock/Paper/Scissors!" )
+ endswitch
+
+endfunction