Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.idea/
node_modules/
node_modules/
*.log

# OS garbage
Thumbs.db
~*
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module.exports = function(grunt) {
}
},
exec: {
compile_less:'lessc ./src/less/ordial.less ./src/css/ordial.css'
compile_less: 'lessc ./src/less/ordial.less ./src/css/ordial.css'
}
});

grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['watch']);
}
};
10 changes: 5 additions & 5 deletions SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
<title>Jasmine Spec Runner v2.0.0</title>

<link rel="shortcut icon" type="image/png" href="vendor/jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="/vendor/jasmine/jasmine.css">
<link rel="stylesheet" type="text/css" href="vendor/jasmine/jasmine.css">

<script type="text/javascript" src="/vendor/jasmine/jasmine.js"></script>
<script type="text/javascript" src="/vendor/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="/vendor/jasmine/boot.js"></script>
<script type="text/javascript" src="vendor/jasmine/jasmine.js"></script>
<script type="text/javascript" src="vendor/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="vendor/jasmine/boot.js"></script>

<script type="text/javascript" src="node_modules/underscore/underscore.js"></script>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="node_modules/backbone/backbone.js"></script>

<script type="text/javascript" src="/vendor/seedrandom/seedrandom.js"></script>
<script type="text/javascript" src="vendor/seedrandom/seedrandom.js"></script>

<!-- include source files here... -->
<script type="text/javascript" src="src/World.js"></script>
Expand Down
36 changes: 27 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

<!doctype html>
<meta charset="utf-8">
<title>Ordial</title>

<script type="text/javascript" src="node_modules/underscore/underscore.js"></script>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="node_modules/backbone/backbone.js"></script>
<script type="text/javascript" src="/vendor/seedrandom/seedrandom.js"></script>
<script type="text/javascript" src="vendor/seedrandom/seedrandom.js"></script>

<script type="text/javascript" src="src/World.js"></script>
<script type="text/javascript" src="src/WorldView.js"></script>
Expand All @@ -25,6 +27,7 @@
<script type="text/javascript" src="src/StimulusPackager.js"></script>
<script type="text/javascript" src="src/TheVoid.js"></script>

<link rel="icon" type="image/x-icon" href="favicon.ico">

<link rel="stylesheet" type="text/css" href="src/css/ordial.css">

Expand Down Expand Up @@ -64,19 +67,19 @@ <h3>Active Code</h3>
var rob = new Critter({mind: new CritterMind({decisionTree: moveForwardOrThink})});

function getCoord() {
return Math.floor(Math.random() * 10);
return Math.floor(Math.random() * 10);
}

function getCoords() {
return {x: getCoord(), y: getCoord()};
return {x: getCoord(), y: getCoord()};
}

for(var i = 0; i < 50; i++) {
world.place(new Resource(), getCoords());
world.place(new Resource(), getCoords());
}
for(var i = 0; i < 50; i++) {
var blocker = new Rock();
world.place(blocker, getCoords());
var blocker = new Rock();
world.place(blocker, getCoords());
}

rob.direction = _.sample(CardinalDirection.ALL_DIRECTIONS);
Expand All @@ -98,7 +101,7 @@ <h3>Finding food</h3>
};

var turnLeftOrTurnRight = new DecisionNode(isNothingToTheLeftOfMe, Critter.Actions.TURN_LEFT, Critter.Actions.TURN_RIGHT);
var eatItOrThink = new DecisionNode(isThingInFrontOfMeEdible, Critter.Actions.MOVE_FORWARD, turnLeftOrTurnRight
var eatItOrThink = new DecisionNode(isThingInFrontOfMeEdible, Critter.Actions.MOVE_FORWARD, turnLeftOrTurnRight);
var moveForwardOrThink = new DecisionNode(isSomethingInFrontOfMe, eatItOrThink, Critter.Actions.MOVE_FORWARD);
var rob = new Critter({mind: new CritterMind({decisionTree: moveForwardOrThink})});

Expand Down Expand Up @@ -127,7 +130,7 @@ <h3>Zig Zag</h3>
var zig = [Critter.Actions.TURN_RIGHT, Critter.Actions.MOVE_FORWARD, Critter.Actions.DECREMENT_COUNTER];
var zag = [Critter.Actions.TURN_LEFT, Critter.Actions.MOVE_FORWARD, Critter.Actions.INCREMENT_COUNTER];
var toZigOrToZagThatIsTheQuestion = function(stimuli, vitals) {
return vitals.counter === 0;
return vitals.counter === 0;
};
var zigZag = new DecisionNode(toZigOrToZagThatIsTheQuestion, zig, zag);
anna = new Critter({mind: new CritterMind({decisionTree:zigZag })});
Expand All @@ -148,3 +151,18 @@ <h3>Turn, Run, and Make Babies</h3>
world.place(new Resource(), {x: 3, y: 4});
</textarea>

<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js"></script>
<script>
$("textarea").each(function(){
var $textarea = $(this);
var $editarea = $("<div/>").insertAfter($textarea);
var editor = ace.edit($editarea[0]);
var session = editor.getSession();
session.setValue($textarea.val());
session.setMode("ace/mode/javascript");
session.on('change', function(){
$textarea.val(editor.getSession().getValue());
});
$textarea.hide();
});
</script>
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@
"email": "[email protected]"
}
],
"main": "./src/ordial.js",
"repository": {
"type": "git",
"url": "https://github.com/segfaultsoftware/ordial.git"
},
"main": "index.html",
"scripts": {
"start": "opener index.html",
"test": "opener SpecRunner.html",
"grunt": "grunt"
},
"dependencies": {
"backbone": "1.1.x",
"jquery": "2.1.x",
"underscore": "1.5.x"
},
"devDependencies": {
"less": "~2.0.0",
"opener": "~1.4.0",
"grunt": "~0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-watch": "~0.6.1",
"grunt-exec": "~0.4.6"
"grunt-exec": "~0.4.6",
"less": "~2.0.0"
}
}
10 changes: 7 additions & 3 deletions src/css/ordial.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@
padding: 0;
border: 0;
}
textarea {
width: 500px;
height: 200px;
textarea,
.ace_editor {
width: 900px;
height: 220px;
}
body {
font-family: sans-serif;
}
11 changes: 8 additions & 3 deletions src/less/ordial.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
@import 'rock';
@import 'world';

textarea {
width: 500px;
height: 200px;
textarea,
.ace_editor {
width: 900px;
height: 220px;
}

body {
font-family: sans-serif;
}