This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define a function to insert a word into a list | |
def insert_word(word, l): | |
if len(l) > 0: | |
# If there's something in the list already, | |
# insert the new word | |
# First split the list into head and tail | |
head = l[0] | |
tail = l[1:] | |
# We can use the < operator in Python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/home/smiley/Downloads/StateMachine04.ino b/StateMachine04_jh_modifi | |
ed.ino | |
index e2c3992..ff24608 100644 | |
--- a/home/smiley/Downloads/StateMachine04.ino | |
+++ b/StateMachine04_jh_modified.ino | |
@@ -1,3 +1,5 @@ | |
+#include <functional> | |
+ | |
// state machine experiments, try #4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textToGame = function(text, seed) { | |
var game = JSON.parse(text) | |
if (game.version != 11) { | |
alert("Invalid version number: " + json_game.version); | |
} | |
//Adds determinism (when used with https://github.com/davidbau/seedrandom) to color scramble. | |
console.log(seed); | |
Math.seedrandom(seed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cardinal_distance_to_edge(loc, direction, limit): | |
if limit > 0: | |
next_step = gameMap.getLocation(loc, direction) | |
site = gameMap.getSite(next_step) | |
if next_step.owner == myID: | |
return 1 + cardinal_distance_to_edge (next_step, direction, limit - 1) | |
else: return 1 | |
else: | |
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIRS = [ | |
((-1, 0), 1), | |
((0, 1), 2), | |
((1, 0), 3), | |
((0, -1), 4) | |
] | |
def wrap (row, col): | |
if row < 0: row = row + gameMap.height | |
if col < 0: col = col + gameMap.width |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This short program was written to clarify in my own head something which | |
* had confused me. If I pass a struct (not a pointer) as an argument to a | |
* function, that function receives a copy of the original struct. Changes | |
* made to that copy will have no effect on the struct in the calling function. | |
* This holds true for arrays inside the struct: the arrays are complete | |
* copies of the originals, not copies of pointers leading to the same place | |
* (as I had for some reason expected). | |
* | |
* The function called bad_manipulate1 shows a simple case demonstrating the | |
* error I made in another program. |