Tag Archives: software

Combined Gas law (part 3)

I’ve just moved forward to hire an artist I like from oDesk. I have mixed experiences from using oDesk in the past, but I really like this artist’s work and I think it will be a good fit for my project.

I finished my final(ish) edit of the first book and am now waiting for some comments from my aunt, who is proofing it for me. If all goes well, there is a chance that this project could be finished by early September. If so, you all will be the first to know.

I started a second storyline that I would like to use to introduce concepts of population ecology today. I might be overly ambitious with this storyline, so I may work two parallel stories to teach the same concepts and see which one gets more traction.


OK – gotta run, my son’s gymnastics camp is just letting out.



Leave a comment

Posted by on August 6, 2012 in Uncategorized


Tags: , , ,

Slightly Unhealthy Obsession

I read a post a week or so ago (I’ll look for a citation) on whether blogging was addictive. Every characteristic of an addicted blogger made by the writer was something that I think I had just done within the past five minutes: obsessive checking of the blog for comments and likes, convulsively watching my blog’s stats for activity and trolling of the blogosphere for similar blogs in order to like them so that they might come visit my page in return.

I admit it, I’m totally addicted. And I need your help.

Oh no, I don’t want to quit. I don’t really want to control it at all. What I’d prefer to have is some satisfying stats. So, to that end, could you please stop by my blog once in a while. Hit ‘like’ and maybe leave a comment. Perhaps subscribe… and then maybe get someone you know to come by and do all that again.

Right now I get a paltry handful of visits a day (I think my record was 41 – I wish I knew what I had done right that day). I’d like to see if I can get some decent numbers by the end of the summer. It would also be good for me because I know that I’ll write more (and better) if I knew there was someone out there reading.

I have two blogs, this one for DownHouse Software (although I drop anything that’s going on in my life here) and AppCampus, which is a little more serious. I’ve been trying to post some articles on technology in education. I’d also appreciate some article ideas if you have any.

So, if you can help my feed my addiction a little, thank you.


Posted by on July 31, 2012 in Personal Life


Tags: , , , , , , , ,

function: compareGuess – the hardest one yet

First – I’m playing with some themes, so sorry about the fact that the site doesn’t look the same. I’m actually having a hell of a time getting things set up in a way that I am happy with and feel like I have sufficient control over.

Second -the new function: compareGuess. This one was a bear! I was wrestling with it forever before I finally got it to work correctly. Well, I hope it works correctly – I’ll post the whole program in the next post so that you can copy and paste it into a Javascript editor / compiler /whatever it’s called.

Why this one was hard is that, in the game, there are two ways you can ‘score’: if you get the right number in the right position, that’s the best(I’m calling that green). You can also get the right number in the wrong position (I’m calling that yellow). The problem is that these are mutually exclusive, with green trumping yellow in a manner of speaking. This is further complicated by the fact that once a number matches, you don’t want to use that same number to match again. This requires an example to illustrate…

secret code is: 112

guess is 123

The first position is a perfect match (green). But then the first position of the guess needs to be ignored when analyzing the rest of the code. If you just nest one loop inside another, you can easily get output of :

1 green

2 yellow

This is because position#1 of the guess matches position#1 of the code= green

but position #1 of the guess also matches position#2 of the code = yellow? -It’s not supposed to be, but how to fix?!?

then, position#2 of guess matches position#3 of the code = yellow (this one’s correctly attributed)

that gives us a total of three match signals when only two are a match!!


My solution (after a long time of playing around) was to add ‘guessedAlready’ and ‘secretedAlready’ Boolean Arrays within the function (It’s really important to keep these arrays private / privileged otherwise, you can run into problems when values get carried over from one guess to the next).

guessedAlready[0] refers to the first position of the guess, i.e. guess[0].

Then I set the arrays to false to start, added statements redefining them as true anytime a match was made and finally added qualifiers to my ‘if’ statements that check to see if each number was guessed already (or part of the secret code already) and therefore should be ignored.

This solution still ran into problems though until I separated my loops and looked for only exact matches (green) first, then went back and looked for inexact matches (yellow). Otherwise, if I found an inexact match in the secret code and then hid it, I couldn’t ‘see’ it for the exact match comparison later. Ughhh. example:

secret code: 112

guess : 212

if guess[0] matches code[2] as above, then we get a yellow peg for an inexact match and then we hide code[2] and don’t see that it should actually be an exact match with guess[2].

So, the function has two major parts. Part#1 loops and looks for greens. Part#2 loops and looks for yellows. Then I added a short Part#3 that sets the # of whites (no match) to white = code -(green+yellow), where code is the number of digits in the code.

I hope that makes sense. I tested this several times last night and it looked good. I will test it more later, but please feel free to make comments if you see a problem. Or ever better: if you can code and are still reading this for some reason, let me know if there is an easier way to solve this problem.

Here’s the code:


var compareGuess = function(code,secrets,guesses){

var green = 1-1; //right color, right position

var yellow = 1-1; //right color, wrong position

var white = 1-1; //wrong color

var guessedAlready=[];

var secretedAlready = [];

code = code*1; //converts code to a number type

//part 0: set ‘Already’ arrays to false

for (i=0; i<code; i++){

guessedAlready[i] = false;

secretedAlready [i]= false;


//part 1: check for perfect matches, alter guesses and secrets

//array positions to eliminate recount – count greens

for (i=0; i<code; i++){

guesses[i] = guesses[i] *1;

//console.log(“I’m in the first loop”);

//console.log(“guess”+i+”=”+guesses[i]+” of type “+typeof guesses[i]);

//console.log(“secret”+i+”=”+secrets[i]+” of type “+typeof secrets[i]);

if (guesses[i] === secrets[i] &&

guessedAlready[i] === false && secretedAlready[i] === false){

//console.log(“I’m in green”);


guessedAlready[i] = true;

secretedAlready[i] = true;



//part2: check for imperfect matches, alter guesses and secrets

//array positions to eliminate recount – count yellows

for(i=0; i<code; i++){

for (j=0; j<code; j++){

if (guesses[i] === secrets[j] &&

guessedAlready[i] === false && secretedAlready[j] === false){


guessedAlready[i] = true;

secretedAlready[j] = true;




//part 3: set white to number of unmatched items

//provide feedback to player

white = code – (green+yellow);

alert(green+” green    ” + yellow+” yellow”+ white+” white”);

console.log(green+” green ” + yellow+” yellow”+ white+” white”);

if (green === code){

exitShowResultLoop = true;








Tags: , , , , , , , ,