RSS

Monthly Archives: July 2012

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.

 
5 Comments

Posted by on July 31, 2012 in Personal Life

 

Tags: , , , , , , , ,

Rain

Not much, but we did actually get some rain last night. I saw the proof this morning when I fed our (outdoor) cat. I can’t say that I believe things are turning around in a meaningful way, but I do have some hope now.

Keep your fingers crossed for us here.

By the way, today is day3 of P90X. I haven’t done the workout yet, but I’m dreading it as I don’t have a muscle in my body that isn’t screaming in pain.

 

 
Leave a comment

Posted by on July 31, 2012 in Uncategorized

 

Tags: , , ,

The word ‘desertification’ keeps coming to mind

Here I am moaning and complaining about the weather again. But I just can’t stand these deathly hot, dry days one after another after another.

I’m reminded of a Star Trek Next Generation episode where Captain Picard wakes up in another man’s life. In this life he’s married and a naturalist who discovers that his planet is suffering from a world-wide drought and, in fact, this life experience is a window into the culture of an extinct world. This isn’t a very good explanation – check it out yourself. The episode is called “Inner Light.”

Please don’t let this drought be the Midwest’s Inner Light. At least not while I’m living here.

 

OK, in other news, I just posted another article to AppCampus about how I think video games can be harnessed to improve education in the sciences (or perhaps any subject).

I also need to put together the work we did here on the Blackjack program (codecademy project) into a neat posting for that site’s message board. I think the whole code with sufficient notation and some commentary should be a valuable contribution there.

 

Image

 
Leave a comment

Posted by on July 31, 2012 in Uncategorized

 

Tags: , , , , , ,

Homecoming

It’s so good to be home!

Even dry and desolate, it’s where my own bed is, with my own pillow and my own family.

I can do with not traveling for a while now.

 

ps –

1.I’ve added a companion blog (AppCampus) where I am writing some serious material about technology and education.

2. Tomorrow is day 1 of P90X

 

 

 
Leave a comment

Posted by on July 29, 2012 in Uncategorized

 

Tags: , , , , , ,

Last Day

Today is the last day of my traveling. We head for home tomorrow morning and I am very eager to get there and fall back into a more predictable, more familiar routine. 

Perhaps it’s travel fatigue. Perhaps it’s just homesickness.

 

 
Leave a comment

Posted by on July 28, 2012 in Uncategorized

 

Tags: , , , , ,

Finishing Touches

Step 6: You get a hand, Determining scores and judging winner

Here are the last touches that make this code into the bare-bones structure of the game. Cards are dealt out to two hands (myHand and yourHand), each card is given a suit and a value and the two hands are compared to determine a winner. (I haven’t added anything about ‘Hitting’ or ‘Holding’, and since you start with only two cards, you can’t go over 21. I’m assuming that these things are all part of the final project).

//Hand Constructor

var Hand = function(){

this.card1 = deal();

//console.log(“card1 is “+this.card1.number+” of ” + this.card1.suit);

this.card2 = deal();

//console.log(“card2 is “+this.card2.number+” of ” + this.card2.suit);

};

//Card Constructor

var Card = function(s,n){

this.number = n;

this.suit = s;

this.getSuit = function(s){

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

switch(this.suit){

case 1:

this.suit = “clubs”;

break;

case 2:

this.suit = “diamonds”;

break;

case 3:

this.suit = “hearts”;

break;

case 4:

this.suit = “spades”;

break;

}

};

this.getValue = function(n){

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

if (n === 1){

this.value = 11;

}

else if (n >= 11){

this.value = 10;

}

else{

this.value = n;

}

};

};

//Deal function

var deal = function(){

var suit = Math.floor(Math.random()*4)+1;

//console.log(“deal function suit: “+suit);

var number = Math.floor(Math.random()*13)+1;

//console.log(“deal function number: “+number);

return new Card(suit,number);

};

//Score function

var score = function(one, two){

return one+two;

};

//comparison of hands

var judgement = function(mine,yours){

if (mine>yours){

console.log(“I win “+mine+ ” vs “+yours);

}

else if (yours>mine){

console.log(“You win “+mine+ ” vs “+yours);

}

else{

console.log(“We tied “+mine+ ” vs “+yours);

}

};

//Main Function

var myHand = new Hand();

myHand.card1.getSuit(myHand.card1.suit);

myHand.card1.getValue(myHand.card1.number);

console.log(“my card1 is a “+myHand.card1.suit+” of value “+myHand.card1.value);

myHand.card2.getSuit(myHand.card2.suit);

myHand.card2.getValue(myHand.card2.number);

console.log(“my card2 is a “+myHand.card2.suit+ ” of value “+myHand.card2.value);

var yourHand = new Hand();

yourHand.card1.getSuit(yourHand.card1.suit);

yourHand.card1.getValue(yourHand.card1.number);

console.log(“your card1 is a “+yourHand.card1.suit+” of value “+yourHand.card1.value);

yourHand.card2.getSuit(yourHand.card2.suit);

yourHand.card2.getValue(yourHand.card2.number);

console.log(“your card2 is a “+yourHand.card2.suit+ ” of value “+yourHand.card2.value);

var myScore = score(myHand.card1.value,myHand.card2.value);

var yourScore = score(yourHand.card1.value,yourHand.card2.value);

judgement(myScore,yourScore);

 

Tags: , , , ,

Adding the Methods

Step5: Adding methods to interpret actual suit and value of cards

 

//Hand Constructor

var Hand = function(){

    this.card1 = deal();

   

    console.log(“card1 is “+this.card1.number+” of ” + this.card1.suit);

    this.card2 = deal();

    console.log(“card2 is “+this.card2.number+” of ” + this.card2.suit);

   

};

 

//Card Constructor

var Card = function(s,n){

    this.number = n;

    this.suit = s;

 

 

            this.getSuit = function(s){

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

     switch(this.suit){

        case 1:

            this.suit = “clubs”;

            break;

        case 2:

            this.suit = “diamonds”;

            break;

        case 3:

            this.suit = “hearts”;

            break;

        case 4:

            this.suit = “spades”;

            break;

     }

            };

 

            this.getValue = function(n){

     console.log(“I’m here in getValue”);

     if (n === 1){

         this.value = 11;

     }

    else if (n >= 11){

        this.value = 10;

    }

     else{

         this.value = n;

     }

            };

};

 

 

//Deal function

var deal = function(){

            var suit = Math.floor(Math.random()*4)+1;

            console.log(“deal function suit: “+suit);

var number = Math.floor(Math.random()*13)+1;

            console.log(“deal function number: “+number);

            return new Card(suit,number);

};

 

//Main Function

var myHand = new Hand();

myHand.card1.getSuit(myHand.card1.suit);

myHand.card1.getValue(myHand.card1.number);

console.log(“card1 is a “+myHand.card1.suit+” of value “+myHand.card1.value);

myHand.card2.getSuit(myHand.card2.suit);

myHand.card2.getValue(myHand.card2.number);

console.log(“card2 is a “+myHand.card2.suit+ ” of value “+myHand.card2.value);

 

 

In this section I added two methods (these are just functions that handle objects). Methods are placed inside of the objects they work on (is this right?Always?). In this program my methods interpret the suit and number variables as the suit that the number represents (clubs, diamonds, etc) and the value of the card (ace = 11, face cards are all worth 10 and numbered cards are worth their numerical value).

As usual, I have included a couple console.log statements so that I could track where problems cropped up along the way.

 

 

Tags: , , , , , ,

Next steps… making the card objects

Step4: Adding the Card Class (called from Deal function)

 

//Hand Constructor

var Hand = function(){

this.card1 = deal();

console.log(“card1 is “+this.card1.number+” of “ + this.card1.suit);

this.card2 = deal();

console.log(“card2 is “+this.card2.number+” of “ + this.card2.suit);

};

 

//Card Constructor

function Card(s,n){

            this.number = n;

this.suit = s;

 

 

            getSuit (method to interpret suit numbers)

 

            getValue(method to interpret value unbers)

 

}

 

//Deal function

var deal = function(){

            var suit = Math.floor(Math.random()*4)+1;

            console.log(“deal function suit: “+suit);

var number = Math.floor(Math.random()*13)+1;

            console.log(“deal function number: “+number);

            return new Card(suit,number);

};

 

//Main Function

var myHand = new Hand();

 

 

New text is highlighted in red(Although I’m not sure this formatting will follow through to the post). Here we are adding a function call at the end of the ‘deal’ function in the form of a ‘return’ statement. This means that the deal function will generate two random numbers for us and then send these to the ‘card’ constructor to make our new card objects.

I’m leaving most of the card object unfinished at this point. We will come back later to add methods for interpreting the information associated with each card object.

 

 
 

Tags: , , , ,

Getting Started with rebuilding blackjack from scratch with notes (help requested)

Using the flowchart in the previous post, I’ve started walking through how to build this program.

Step 1: Outline:

 

Hand Constructor

 

Card Constructor

 

            getSuit (method to interpret suit numbers)

 

            getValue(method to interpret value unbers)

 

Deal function

 

Main Function

 

 

 

 

 

Step2: Fleshing out early program (make myHand)

 

//Hand Constructor

var Hand = function(){

this.card1 = deal();

console.log(“card1 is “+this.card1.number+” of “ + this.card1.suit);

this.card2 = deal();

console.log(“card2 is “+this.card2.number+” of “ + this.card2.suit);

};

 

Card Constructor

 

            getSuit (method to interpret suit numbers)

 

            getValue(method to interpret value unbers)

 

Deal function

 

//Main Function

var myHand = new Hand();

 

The main function immediately generates a hand “myHand” for the player.

Going to the Hand constructor, we know that we need two cards, and that they will be made by calling the deal function. I’ve included a console.log to immediately provide feedback showing that the cards have correct properties (simple numbers right now)

 

 

Step3: Generating cards with the ‘Deal’ function

 

//Hand Constructor

var Hand = function(){

this.card1 = deal();

console.log(“card1 is “+this.card1.number+” of “ + this.card1.suit);

this.card2 = deal();

console.log(“card2 is “+this.card2.number+” of “ + this.card2.suit);

};

 

Card Constructor

 

            getSuit (method to interpret suit numbers)

 

            getValue(method to interpret value unbers)

 

//Deal function

var deal = function(){

            var suit = Math.floor(Math.random()*4)+1;

            console.log(“deal function suit: “+suit);

var number = Math.floor(Math.random()*13)+1;

            console.log(“deal function number: “+number);

};

 

//Main Function

var myHand = new Hand();

 

Deal is called twice from the Hand Constructor. We should flesh out the deal function now. This function generates two random numbers (‘suit’ : 1-4) and (‘number’ : 1-13).

As before, I’ve added some console.log statements to make sure this is working correctly. I include a statement about being in the deal function as a check for how the program is walking through its steps.

Problem of Scope: am I making variables with appropriate scope in this function?

 

 
Leave a comment

Posted by on July 24, 2012 in Codecademy, Coding

 

Tags: , , , , , ,

Blackjack Flow

In order to make sense of the blackjack project, I made up this flow diagram to describe how the program creates ‘Hand’ objects consisting of two ‘card’ objects, and that these cards have properties that need to be generated and interpreted. The two properties are number (1-13, where 1 is Ace, 11 is Jack, 12, is Queen, etc) and suit (1-4, where each number is a given suit).

The properties of the cards can be set using a function, deal.

Once cards are made, they use two methods (because we are handling objects) to interpret the suit and value of each card.

Finally, we have two cards in a hand and can proceed to the next step…

Here’s a flow diagram of this process:Image

 
1 Comment

Posted by on July 24, 2012 in Codecademy, Coding

 

Tags: , , , ,