Thursday, November 5, 2009

An Algorithm to Find the Greatest Common Divisor (Non-Recursive) (Very Inefficient)

function greatestCommonDivisor = greatestCommonDivisor(num1, num2)
facNum1 = factor(num1);
facNum2 = factor(num2);
index1 = 1;
index2 = 1;
greatestCommonDivisor = 1;
if facNum1(index1) == facNum2(index2)
greatestCommonDivisor = greatestCommonDivisor * facNum1(index1);
facNum2(index2) = 1;
end
index1 = 2;
index2 = 2;
while index1 <= length(facNum1) - 1
while index2 <= length(facNum2) - 1 && facNum1(index1) ~= facNum2(index2)
index2 = index2 + 1;
end
if facNum1(index1) == facNum2(index2)
greatestCommonDivisor = greatestCommonDivisor * facNum2(index2);
facNum2(index2) = 1;
end
index1 = index1 + 1;
end

Oh My Stars and Garters

Over at Maggie's Farm they're tossing up oooooold predictions of "technology of tomorrow" type stuff. I remember seeing/watching the same kind of thing when I was a kid (albeit the stuff I watched was more flying cars and giant holograms / circa 1990s don'cha'know). Still, amazing to see how far off the mark predictions can be, or how close to the future they can be.
(H/T Captain Capitalism)

Still, kinda makes me wonder, with the increasing amounts of red tape and gov't bureaucracy involved in getting patent rights these days (and the increasing amount of frivolousness allowed with some patents)... I wonder what, if any, future technology is gonna come about by, say, 2050. Obviously the incremental decrease in size of transistors and increasing use of high speed fiber-optic technologies are going to continue, but what about entirely new devices, or ways of doing things?

Don't really want to sink into paranoia (oh noes, net neutrality!) but I think the looks of things in a general sense leave me somewhat cynical, at least to a certain extent. Will say the allosphere project looks damn cool, though. On second thought, maybe I'm not all that pessimistic that technology will advance, but I am pessimistic about the pace. C'mon people, let's get our priorities straight: Socialism in the name of helping the poor (and ultimately only increasing the # of poor) or eliminating the corporate tax and letting the sky be the limit on technological investment and innovation?

Factorization Algorithm in MATLAB

function factor = factor(number)
factor(1) = 0;
tempVal = number;
numFactors = 0;
divisor = 2;
modulo = intDivision(tempVal, divisor);
while isPrime(tempVal) == 0
while modulo(2) > 0
divisor = divisor + 1;
modulo = intDivision(tempVal, divisor);
end
if modulo(2) == 0
numFactors = numFactors + 1;
factor(numFactors) = divisor;
tempVal = modulo(1);
modulo = intDivision(tempVal, divisor);
end
end
numFactors = numFactors + 1;
factor(numFactors) = tempVal;

IsPrime Implemented in MATLAB (Using IntDivision Implementation)

function isPrime = isPrime(number)
if number == 2 %base case
isPrime = 1;
return;
end

divisor = 2;
modulo = intDivision(number, divisor);
while modulo(2) > 0 && divisor <= sqrt(number)
divisor = divisor + 1;
modulo = intDivision(number, divisor);
end
if modulo(2) > 0
isPrime = 1;
return;
end
isPrime = 0;
return;

Algorithm Which Returns the Next Prime After the Number Entered

function nextPrime = nextPrime(number)
number = number + 1;
while isPrime(number) == 0
number = number + 1;
end
nextPrime = number;

An Algorithm For Dividing Integers (Returning the Quotient and the Remainder) in MATLAB

function quotient = intDivision(dividend, divisor)
if divisor > dividend
quotient = [0, dividend];
return;
end
if divisor == 0
quotient = [0, 0];
return;
end
counter = 0;
tempVal = 0;
while tempVal <= dividend
tempVal = tempVal + divisor;
counter = counter + 1;
end
if tempVal == dividend
quotient = [counter, 0];
return;
end
tempVal = tempVal - divisor;
quotient = [counter - 1, dividend - tempVal];

Wednesday, November 4, 2009

Binary Morality and other Religious Quandaries

So, I had a conversation the other day with one of my classmates about religion and the way we view morality; both of us are in a discrete math class and we came up with a few basic axioms of religion we figured were mutually exclusive (that is, only one can be true):

A) There is one and only one God
B) There are many gods
C) There is no god

Here we would likely define the "kami" of Shintoism and the boddhisatvas of Buddhism as a religion favoring the many gods axiom (as well as similar beliefs).

As much as everyone would like to be accepting or tolerant, this is kind of the way it is: By believing in any particular religion you are accepting the premise that people who don't believe the same way you do about one of the basic axioms are wrong.

Settling that, we started talking about pretty nebulous ideas like justice, mercy, and morality in general. We were mostly talking about Protestantism vs LDS beliefs (since my classmate is LDS and I'm a Protestant with LDS uncles, aunts, and cousins). In talking about the idea of justice, I put forth the idea that justice as we see it is entirely subjective; that is, we see a theft and we judge that a relatively short term of imprisonment is payment enough, but the rape and murder of a child deserves life imprisonment or capital punishment: death.

Now, again this is entirely subjective because, at least in my understanding of the Bible, God sees sin simply as a sin. It has neither a gradient nor is it cumulative. All of that comes down to a premise of mine about the way God looks at things. I think if we think of it in binary terms (1 is clean of sin, 0 is sinful), you can only attain '1' by either accepting Jesus as your savior, or by being Jewish and practicing the cleansing rituals. If we further pontificate on the verses about man being inherently imperfect and the flesh being naturally tempted toward sin, it stands to reason that '0' is the default state; and everyone under completely "fair and just" circumstances deserves to go to Hell (or whatever you wanna call your local burning pit of eternal torment). Me included.

Now when it comes to the idea of justice and mercy, my classmate was saying that you cannot receive mercy from the same entity/being as you would have received justice; that there has to be a third party for God to be "eternally unchanging." And here we went into a friendly debate about the nature of the Trinity (which is one of the main rift points between LDS and other Christians, a big enough point IMO to disinclude LDS as one of the sects of Christianity).

From my interpretation, the trinity is a set of 3 different manifestations of the same being. "The Father" is sort of the general-purpose manifestation that we envision ourselves praying to, that we think of as being on a golden throne in heaven, etc etc yada yada yada. "The Son" is Jesus, the savior, the messiah, the one we think of as lending the merciful hand (some people would even envision him as the defense attorney on our behalf before the Father in some place of ultimate judgement). Last is "The Holy Ghost/Spirit" which is how some envision the conscience, that which nudges us in the right direction when we come to a moral decision (though I think of my own conscience as something separate, and the Holy Ghost is more, God acting as the universal hint system). But anyway, all three manifestations are just our own vision or idea about how things are, like looking at a C++ or Java implementation when what's in Assembly (or even just binary machine language) tells a slightly different story. All 3 are really the same entity.

As for how my classmate interpreted it, it goes back to the argument about God (The Father) being unchanging and incapable of offering Justice and Mercy at the same time; thereby necessitating a third party in the form of Jesus Christ, who under this understanding must be seen as a separate entity than The Father.

Well, if I misunderstood any of that (classmate who may or may not read this) feel free to correct me; and I'd love to hear others' opinions on the matter in the comments.

Tuesday, November 3, 2009

Since It's Election Day...

It calls for some Alice Cooper:

A Discussion on Labels

So, checking out Gadfly's site and I came across some interesting ideas from Conservative Wahoo about coining "neo-socialism" as a term to describe the Obama administration's leanings.

I think the main problem I have with the phrase is that it's suggesting that A) Obama has really thought out his positions in a meaningful way, and B) this administrations ideas ARE new which is something of a fallacy.

Addressing point A, the impression that I've gotten from Obama, from the very beginning was that he was a political opportunist, above all else. This is perhaps why Edward Kennedy (black spot on the Kennedy name as he is/was) endorsed him, maybe sensing a kinship in the lack of a real philosophical foundation upon which to base his politics. The kind of people he associates/d himself with are not just left-leaning radicals, they are also corrupt in every sense of the word (Blago, Rezko, even the scams that went on where Michelle O worked. I'm not saying he's not pursuing socialist-style philosophies, but rather, it's not clear that he's philosophically motivated in the first place. It is therefore a case of jumping the gun to coin a term to define the philosophy backing his policies.

To address point B, I'll go back to the fallacy we were indoctrinated into believing in high school economics and US history, as well as what I've seen in college economics classes. That is, that Karl Marx and John Maynard Keynes presented ideas which were new and untried. If we go back to the "age of enlightenment" in 1700s France we find the same basic ideas from the likes of Rousseau and before that, back to the Greek philosophers you have some branches of stoicism relating much the same ideas. As far as policies based on political philosophies, a lot of the considerations about a federally controlled national bank issuing money and purposefully inflating it have been tried throughout history; by the Khans during their control of China; by the French (again under absolutism in the 1700s) and even a bit of the same under the era of Mercantilism by the British and the Dutch. I could go on but I think you get my drift: Obama's ideas, much the same as Marx's, are not in any sense new. They've been tried by many people in many places in many eras, and have never worked. Period. Constantly trying to reinvent the wheel is not going to lead to major progress (another word relating back to another group of people who tried and failed at centrally planned economies).

To add even more confusion to the mix, the term "liberal" which is now used to generally reference a person with the same ideas as all the bozos I just mentioned, actually used to refer to us; that is, conservatism today is/was also referred to as liberalism at least up until the 1930s or so. In fact, the "movement" of "neoliberalism" is in fact a move towards freeing markets from overactive government regulators. I just wish there was some easy way to wipe all these ideas and policies that have essentially been proven wrong, time and time again, to be thrown off the political map; they don't belong.

Apologies...

Code is an interesting thing to try and post online, since when you try and post it straight from a .h or .cpp file, it often includes less than and greater than signs, which in html means something entirely different, so if you see a blank space, that means there's supposed to be something there, it would just be enclosed in a less than and greater than sign... I'll have to figure out some way to fix that..

Monday, November 2, 2009

getData function example in C++

//getData function ~ validates that the input is of the correct data type
template<class T>
void getData(T data, string prompt)
     {
          T input;
          for(;;)
          {
               cout << prompt; cin >> input;
               if(cin.good())
               break;
               cout << "Error:  bad input.  Try again.\n";
               cin.clear();
               cin.ignore(10);
          }
          data = input;
      }

List Class

/* List Class Template File
Title: CS 1410 Lab 13 - List Template
Author: Daniel J. Tanner
Date: April 10, 2006
*/
#ifndef TANNLIST_H
#define TANNLIST_H

#include
#include
#include
using namespace std;

namespace Metzengerstein
{
//class declaration
template
class List
{
public:
List(){head_ = NULL;}
List(const List & someList);
~List();
void append(const T & newData);
void insert(int index, const T & newData);
void erase(const T & oldData);
void clear();
void display();
List operator=(const List & someList);
private:
struct Node
{
friend List;
T data;
Node * next;
Node(const T & newData, Node * newNext = NULL){data = newData; next = newNext;}
};
Node * head_;
};

//function definitions
//copy constructor
template
List::List(const List & someList)
{
Node * curr = head_;
Node * temp = someList.head_;
while(temp != NULL)
{
curr = new Node(temp->data);
curr = curr->next;
temp = curr->next;
}
}

//Operator = overloader ~ makes = do something appropriate for dynamically
//allocated list
template
List List::operator=(const List & someList)
{
Node * curr = head_;
Node * temp = someList.head_;
while(temp != NULL)
{
curr = new Node(temp->data);
curr = curr->next;
temp = curr->next;
}
}
//Destuctor ~ properly destroys list after it is used
template
List::~List()
{
Node * temp;
while(head_ != NULL)
{
temp = head_;
head_ = head_->next;
delete temp;
}
}

//Display function ~ Traverses the list to display the contents
template
void List::display()
{
Node * curr = head_;
while(curr != NULL)
{
cout << curr->data << ' ';
curr = curr->next;
}
}

//append function ~ adds a new node at the end of the list
template
void List::append(const T & newData)
{
if(head_ == NULL)
head_ = new Node(newData);
else
{
Node * curr = head_;
while(curr->next != NULL)
curr = curr->next;
curr->next = new Node(newData);
}
}

//erase function ~ erases the first item in the list with data equivalent
//to the given data
template
void List::erase(const T & oldData)
{
if(head_ != NULL)
{
//special case ~ first item is the one that needs erasing
if(head_->data == oldData)
{
Node *curr = head_;
delete curr;
head_ = NULL;
return;
}

//regular cases
Node *prev = head_, *curr = head_;
while(curr->next != NULL && curr->data != oldData)
{
prev = curr;
curr = curr->next;
}
if(curr->data == oldData)
{
prev->next = curr->next;
delete curr;
}
else
return;
}
}

//insert function ~ inserts an item at the index given -- or at the beginning
//or end depending on the index given
template
void List::insert(int index, const T & newData)
{
Node *curr, *prev;
if(index <= 0 || head_ == NULL)
head_ = new Node(newData, head_);
else
{
curr = head_;
for(int count = 1; curr->next != NULL && count < index; count++)
{
prev = curr;
curr = curr->next;
}
if(curr->next == NULL && count < index)
append(newData);
else
prev->next = new Node(newData, curr);
}
}

//clear function ~ clears all the nodes from a list
template
void List::clear()
{
Node * temp;
while(head_ != NULL)
{
temp = head_;
head_ = head_->next;
delete temp;
}
}
}

#endif

Shape Class (.cpp file)

/*
Title: Lab 10 - Polymorphism ~ Shape Classes Definitions
Author: Daniel J. Tanner
Date: March 12th, 2006
Class: CS 1410
*/

#include
#include
#include
#include "TannShape.h"
using namespace std;
using namespace Metzengerstein;

namespace Metzengerstein
{
//Triangle Class Definitions
// Constructors ~ To set the sides variable to explicit or default values
Triangle::Triangle()
{
for(int count = 0; count < 3; count++)
sides_[count] = 0;
}

Triangle::Triangle(double sideA, double sideB, double sideC)
{
sides_[0] = sideA; sides_[1] = sideB; sides_[2] = sideC;
}

//Set functions ~ Set the sides to explicit values
void Triangle::setSides(double sideA, double sideB, double sideC)
{
sides_[0] = sideA; sides_[1] = sideB; sides_[2] = sideC;
}

void Triangle::setSides(double * sides)
{
for(int count = 0; count < 3; count++)
sides_[count] = sides[count];
}

//GetArea function ~ returns the area of the Triangle
double Triangle::getArea()const
{
double s = 0;
for(int count = 0; count < 3; count++)
s += sides_[count];
s /= 2;
return sqrt(s * (s - sides_[0]) * (s - sides_[1]) * (s - sides_[2]));
}

/*Print Function
Purpose: To print out the labelled content of a triangle
*/
void Triangle::print()const
{
cout << "Side lengths: " << sides_[0] << ", " << sides_[1] << ", " << sides_[2];
cout << endl;
cout << "Perimeter: " << getPerimeter();
cout << endl;
cout << "Area: " << getArea();
cout << endl;
}
//End Triangle Definition

//Circle Class Definition
//Print Function ~ Prints out the circle info in an appropriate manner
void Circle::print()const
{
cout << "Radius: " << radius_
<< endl
<< "Circumference: " << getPerimeter()
<< endl
<< "Area: " << getArea()
<< endl;
}
//End Circle Definition

//Rectangle Class Definition
//Print Function ~ Prints out rectangle info appropriately
void Rectangle::print()const
{
cout << "Length: " << length_
<< endl
<< "Width: " << width_
<< endl
<< "Perimeter: " << getPerimeter()
<< endl
<< "Area: " << getArea()
<< endl;
}
//End Rectangle Definition

//Square Class Definition
//Print Function ~ Prints out square info appropriately
void Square::print()const
{
cout << "Side: " << getLength()
<< endl
<< "Perimeter: " << getPerimeter()
<< endl
<< "Area: " << getArea()
<< endl;
}
//End Square Class Definition
}

Polymorphism / Class Heirarchy examples ~ Shapes

/*
Title: Lab 10 - Polymorphism ~ Shape Classes Declarations
Author: Daniel J. Tanner
Date: March 12th, 2006
Class: CS 1410
*/

#ifndef TANNSHAPE_H
#define TANNSHAPE_H

#include
#include
#include
using namespace std;

namespace Metzengerstein
{
//named constants
const double PI = 3.141592654;

//Shape Class declaration
class TannShape
{
public:
virtual double getArea()const = 0;
virtual double getPerimeter()const = 0;
virtual void print()const = 0;
};

//Triangle Class Declaration
class Triangle : public TannShape
{
public:
Triangle();
Triangle(double sideA, double sideB, double sideC);
void setSides(double sideA, double sideB, double sideC);
void setSides(double * sides);
virtual double getArea()const;
virtual double getPerimeter()const{return sides_[0] + sides_[1] + sides_[2];}
virtual void print()const;
private:
double sides_[3];
};

//Rectangle Class Declaration
class Rectangle : public TannShape
{
public:
Rectangle(){width_ = 0; length_ = 0;}
Rectangle(double length, double width){width_ = width; length_ = length;}
void setLength(double length){length_ = length;}
void setWidth(double width){width_ = width;}
double getWidth()const{return width_;}
double getLength()const{return length_;}
virtual double getArea()const{return length_ * width_;}
virtual double getPerimeter()const{return 2 * width_ + 2 * length_;}
virtual void print()const;
private:
double length_;
double width_;
};

//Circle Class Declaration
class Circle : public TannShape
{
public:
Circle(){radius_ = 0;}
Circle(double radius){radius_ = radius;}
void setRadius(double radius){radius_ = radius;}
double getRadius()const{return radius_;}
virtual double getArea()const{return PI * pow(radius_, 2);}
virtual double getPerimeter()const {return PI * 2 * radius_;}
virtual void print()const;
private:
double radius_;
};

//Square Class Declaration
class Square : public Rectangle
{
public:
Square() : Rectangle(0,0){}
Square(double side) : Rectangle(side, side){}
void setSide(double side){setLength(side); setWidth(side);}
virtual void print()const;
double getSide()const{return getLength();}
};
}
#endif

Rational class (cpp file)

/*
Title: Rational class function definitions
Author: Daniel Tanner
Date: August 2nd, 2005
Class: CPSC 1720
*/

//TannRational class function declarations
#include
#include
#include
#include "tannRational.h"
using namespace std;

/* constructors
Purpose: to allow for a default and special constructor
*/
TannRational::TannRational() {numerator_ = 1; denominator_ = 1;}
TannRational::TannRational(int numer, int denom)
{
numerator_ = numer;
if(denom == 0)
zeroError();
else
denominator_ = denom;
reduce();
}

/* Set Functions
Purpose: To set the numerator, denominator, or both
*/
void TannRational::setRational(int numerator, int denominator)
{
numerator_ = numerator;
if(denominator == 0)
zeroError();
else
denominator_ = denominator;
reduce();
}
void TannRational::setRational(TannRational ratio2)
{
numerator_ = ratio2.getNumerator();
denominator_ = ratio2.getDenominator();
reduce();
}
void TannRational::setNumerator(int numerator) {numerator_ = numerator;}
void TannRational::setDenominator(int denominator)
{
if(denominator == 0)
zeroError();
else
denominator_ = denominator;
}

/* Get Functions
Purpose: To return the numerator or the denominator
*/
int TannRational::getNumerator()const {return numerator_;}
int TannRational::getDenominator()const {return denominator_;}

/* Denominator = 0 error
Purpose: If user has set 0 as the denominator, make him change it
Output: Error Message
Input: New Denominator
*/
void TannRational::zeroError()
{
int denom2;
cout << "Error: Computer cannot process ratios with denominator of 0.\n"
<< "Please input a correct denominator: ";
cin >> denom2;
while(denom2 == 0)
{
cout << "Try again. Enter any integer except 0: ";
cin >> denom2;
}
denominator_ = denom2;
}
/* reduce function
Purpose: to reduce a given fraction down to its lowest denominator
Ref: a numerator and denominator that it is reducing
*/
void TannRational::reduce()
{
//create a temporary variable which will be used to reduce
int reducer;

//change the negative sign to numerator if denominator is negative
if(numerator_ > 0 && denominator_ < 0)
{
numerator_ -= numerator_ * 2;
denominator_ = abs(denominator_);
}

//if both numerator & denominator are negative, change to positive
if(numerator_ < 0 && denominator_ < 0)
{
numerator_ = abs(numerator_);
denominator_ = abs(denominator_);
}

//set the reducer to whichever variable is lower between the num & denom
if(abs(numerator_) >= (denominator_))
reducer = abs(denominator_);
else
reducer = abs(numerator_);

//Create a loop to find the highest common multiple between the two
while((((numerator_ % reducer) != 0) || ((denominator_ % reducer)) != 0) && (reducer != 0))
{
reducer--;
}

//reduce with reducer that is divisible by both numer & denom
if(reducer != 0)
{
numerator_ /= reducer;
denominator_ /= reducer;
}
}
/* Print Function
Purpose: To Print out the rational in the form numerator/denominator
*/
void TannRational::printRational()
{
cout << getNumerator() << '/' << getDenominator();
}

/* Add Function
Purpose: to return the sum of two rationals
Return: the sum
*/
TannRational TannRational::add(int numer2, int denom2)
{
TannRational sum;
sum.setNumerator(numerator_ * denom2 + denominator_ * numer2);
sum.setDenominator(denominator_ * denom2);
sum.reduce();
return sum;
}

/* Subtract Function
Purpose: to return the difference between this Ratio and another
Return: the difference
*/
TannRational TannRational::subtract(int numer2, int denom2)
{
TannRational diff;
diff.setNumerator(numerator_ * denom2 - denominator_ * numer2);
diff.setDenominator(denominator_ * denom2);
diff.reduce();
return diff;
}

//Operator Overloaders
//Purpose: To overload the various operators so as to work better with ratios
TannRational TannRational::operator=(const TannRational &right)
{
numerator_ = right.getNumerator();
denominator_ = right.getDenominator();
return *this;
}

/*math operator overloaders
Purpose: To overload the 4 basic math operators to work with a rational
*/
//addition operator overloader
TannRational TannRational::operator+(const TannRational &right)const
{
TannRational sum;
sum.numerator_ = numerator_ * right.denominator_ + denominator_ * right.numerator_;
sum.denominator_ = denominator_ * right.denominator_;
sum.reduce();
return sum;
}

//subtraction operator overloader
TannRational TannRational::operator-(const TannRational &right)const
{
TannRational diff;
diff.numerator_ = numerator_ * right.denominator_ - denominator_ * right.numerator_;
diff.denominator_ = denominator_ * right.denominator_;
diff.reduce();
return diff;
}

//multiplication operator overloader
TannRational TannRational::operator*(const TannRational &right)const
{
TannRational product;
product.setNumerator(numerator_ * right.getNumerator());
product.setDenominator(denominator_ * right.getDenominator());
product.reduce();
return product;
}

//division operator overloader
TannRational TannRational::operator/(const TannRational &right)const
{
TannRational quotient;
quotient.setNumerator(numerator_ * right.getDenominator());
quotient.setDenominator(denominator_ * right.getNumerator());
quotient.reduce();
return quotient;
}

//prefix ++ operator overloader
TannRational TannRational::operator++()
{++numerator_; reduce(); return *this;}

//prefix -- operator overloader
TannRational TannRational::operator--()
{--numerator_; reduce(); return *this;}

//postfix ++ operator overloader
TannRational TannRational::operator++(int)
{TannRational temp(*this); ++numerator_; reduce(); return temp;}

//postfix -- operator overloader
TannRational TannRational::operator--(int)
{TannRational temp(*this); --numerator_; reduce(); return temp;}

//relational operators overloaders
bool TannRational::operator>(const TannRational &right)const
{
TannRational temp;
temp = *this - right;
if(temp.getNumerator() > 0)
return true;
else
return false;
}

bool TannRational::operator<(const TannRational &right)const
{
return right > *this;
}

bool TannRational::operator==(const TannRational &right)const
{
if(this->numerator_ * right.getDenominator() == this->denominator_ * right.getNumerator())
return true;
else
return false;
}

bool TannRational::operator!=(const TannRational &right)const
{
if(*this == right)
return false;
else
return true;
}

bool TannRational::operator>=(const TannRational &right)const
{
TannRational temp;
temp = *this - right;
if(temp.getNumerator() >= 0)
return true;
else
return false;
}

bool TannRational::operator<=(const TannRational &right)const
{
return right >= *this;
}

//I/O Operator Overloaders
ostream &operator<<(ostream &strm, TannRational &obj)
{
strm << obj.numerator_ << "/" << obj.denominator_;
return strm;
}

istream &operator>>(istream &strm, TannRational &obj)
{
strm >> obj.numerator_ >> obj.denominator_;
return strm;
}

//Type Conversion Overloaded Operators
TannRational::operator double()
{
return static_cast(numerator_) / static_cast(denominator_);
}

An implementation of a rational class (good use of operator overloading)

/*
Title: Rational class definition
Author: Daniel Tanner
Date: August 2nd, 2005
Class: CPSC 1720
*/

#ifndef TANNRATIONAL_H
#define TANNRATIONAL_H
#include
#include
using namespace std;

//Rational Class Definition
class TannRational
{
//I/O operator Overloaders
friend ostream &operator<<(ostream &strm, TannRational &obj);
friend istream &operator>>(istream &strm, TannRational &obj);
public:
TannRational();
TannRational(int numer, int denom);
void setRational(int numerator, int denominator);
void setRational(TannRational ratio2);
void setNumerator(int numerator);
void setDenominator(int denominator);
int getNumerator()const;
int getDenominator()const;
void printRational();
TannRational add(int numerator2, int denominator2);
TannRational subtract(int numerator2, int denominator2);

//Operator Overloaders
TannRational operator=(const TannRational &right);
TannRational operator+(const TannRational &right)const;
TannRational operator-(const TannRational &right)const;
TannRational operator*(const TannRational &right)const;
TannRational operator/(const TannRational &right)const;
TannRational operator++();
TannRational operator++(int);
TannRational operator--();
TannRational operator--(int);

//Relational Operator Overloaders
bool operator>(const TannRational &right)const;
bool operator<(const TannRational &right)const;
bool operator==(const TannRational &right)const;
bool operator!=(const TannRational &right)const;
bool operator>=(const TannRational &right)const;
bool operator<=(const TannRational &right)const;

//Type Conversion Overloaded Operator
operator double();

private:
int numerator_;
int denominator_;
void reduce();
void zeroError();
};

#endif

Date Class .cpp

/*
Title: Date Class (.cpp file) - implementation
Author: D. Tanner
class: CS 1415
Date: January 5th, 2006
*/

#include "TannDate.h"

//Date Class implementations - Constructors
/* Default Constructor
Purpose: To create an object of class Date with the date at time of\
creation as the default values
Rec./Ref.: N/A
Return: N/A
*/
TannDate::TannDate()
{
//create a string that will hold the current system date
//collected w/ the strdate function
char currentDate[10];
_strdate(currentDate);

//change the different parts of the array into an int
int month = ((currentDate[0] - 48) * 10) + (currentDate[1] - 48);
int dayOfMonth = ((currentDate[3] - 48) * 10) + (currentDate[4] - 48);
int year = 2000 + ((currentDate[6] - 48) * 10) + (currentDate[7] - 48);
setDate(month, dayOfMonth, year);
}

/* Explicit Value Constructor - with month as a number
Purpose: To provide a way to create a Date object with a user-chosen date
Rec./Ref: N/A
Return: N/A
*/
TannDate::TannDate(int month, int dayOfMonth, int year)
{
setDate(month, dayOfMonth, year);
}

/* Explicit Value Constructor - w/ only the day of the year (0-365)
Purpose: same as above, only here the user can give the day of the year
*/
TannDate::TannDate(int dayOfYear, int year)
{
setDate(dayOfYear, year);
}

//Set Functions
void TannDate::setDate(int month, int dayOfMonth, int year)
{
//validate the info except for monthName
if(month < 1 || month > 12)
{
cout << "Incorrect month. Exiting program..."; exit(1);
}
else if(year % 4 && (dayOfMonth < 1 || dayOfMonth > DAYS_PER_MON[month - 1]))
{
cout << "error: Incorrect day of month. Exiting program..."; exit(1);
}
else if(dayOfMonth < 1 || dayOfMonth > DAYS_PER_MON_LPYR[month - 1])
{
cout << "error: Incorrect day of month. Exiting program..."; exit(1);
}
else if(year < 0)
{
cout << "error: Incorrect year. Exiting program..."; exit(1);
}
else

{ //set the data members
setMonth(month); setDayOfMonth(dayOfMonth); setYear(year);
calcMonthName(); calcDayOfYear();
}
}

void TannDate::setDate(int dayOfYear, int year)
{
//validation
if(year % 4 && (dayOfYear < 1 || dayOfYear > 365))
throw BadDate("error: incorrect day of year");
else if(dayOfYear < 1 || dayOfYear > 366)
throw BadDate("error: incorrect day of year");

//set data members
setDayOfYear(dayOfYear); setYear(year);
calcFromDayOfYear(); calcMonthName();
}

//Calculation functions - these will calculate some data members when others
//have appropriate values

/* CalcFromDayOfYear
Purpose: To calculate the month & day from the day of the year
Rec./Ref.:N/A
Return: N/A
*/
void TannDate::calcFromDayOfYear()
{
//create variables
int tempDays = dayOfYear_;
int count = 0;

//find the month and dayOfMonth by subtracting the # of days in each month
while(tempDays > 31)
{
if(year_ % 4)
tempDays - DAYS_PER_MON[count];
else
tempDays - DAYS_PER_MON_LPYR[count];
count ++;
}
setMonth(count + 1);
setDayOfMonth(tempDays);
}

/* Calc DayOfYear
Purpose: To calculate the day of the year from the month and day of month
*/
void TannDate::calcDayOfYear()
{
int dayOfYear = 0;
for(int count = month_ - 1; count > 0; count--)
{
if(year_ % 4)
dayOfYear += DAYS_PER_MON[count];
else
dayOfYear += DAYS_PER_MON_LPYR[count];
}
dayOfYear += dayOfMonth_;
setDayOfYear(dayOfYear);
}

/* Calc MonthName
Purpose: To calculate the name of the month based on the number
*/
void TannDate::calcMonthName()
{
switch(month_)
{
case 1:
setMonth("January");
break;
case 2:
setMonth("February");
break;
case 3:
setMonth("March");
break;
case 4:
setMonth("April");
break;
case 5:
setMonth("May");
break;
case 6:
setMonth("June");
break;
case 7:
setMonth("July");
break;
case 8:
setMonth("August");
break;
case 9:
setMonth("September");
break;
case 10:
setMonth("October");
break;
case 11:
setMonth("November");
break;
default:
setMonth("December");
break;
}
}

//Print Date Functions

/* Shorthand version
Purpose: To print out the date in shorthand format (MM/DD/YY)
*/
void TannDate::printShortDate()
{
cout << month_ << "/" << dayOfMonth_ << "/" << year_;
}

/* Long version
Purpose: To display a date in the form Month Day Of Month, Year
*/
void TannDate::printLongDate()
{
cout << monthName_ << ' ' << dayOfMonth_ << ", " << year_;
}

/* Day of Year Version
Purpose: To display a date in the form: Day of Year, Year
*/
void TannDate::printDOY()
{
cout << dayOfYear_ << ", " << year_;
}

An example of a date class in C++

Tossing some of these up here for my own reference:

/*
Title: Date Class (header file) - prototype
Author: D. Tanner
class: CS 1415
Date: January 5th, 2006
*/

#ifndef TANNDATE_H
#define TANNDATE_H

#include
#include
#include
using namespace std;

//Constants
const int DAYS_PER_YEAR = 365;
const int DAYS_PER_LPYR = 366;
const int DAYS_PER_MON[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
31};
const int DAYS_PER_MON_LPYR[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31,
30, 31};

//Date class function declarations
class TannDate
{
private:
int dayOfYear_;
int dayOfMonth_;
int month_;
int year_;
string monthName_;

//General Calculation Functions
//These functions must be called only under the circumstances that the
//corresponding data members have been given appropriate values
void calcDayOfYear();
void calcFromDayOfYear();
void calcMonthName();

//private set functions
void setDayOfYear(int dayOfYear){dayOfYear_ = dayOfYear;}
void setDayOfMonth(int dayOfMonth){dayOfMonth_ = dayOfMonth;}
void setMonth(int month){month_ = month;}
void setMonth(string monthName) {monthName_ = monthName;}
void setYear(int year){year_ = year;}

public:
//Exception class
class BadDate
{
private:
string errorMsg_;

public:
BadDate(string error){errorMsg_ = error;}
string getError(){return errorMsg_;}
};

//Get functions
int getDayOfYear(){return dayOfYear_;}
int getDayOfMonth(){return dayOfMonth_;}
int getMonth(){return month_;}
int getYear(){return year_;}
string getMonthName(){return monthName_;}

//set functions
void setDate(int month, int dayOfMonth, int year);
void setDate(int dayOfYear, int year);

//Constructors
TannDate();
TannDate(int month, int dayOfMonth, int year);
TannDate(int dayOfYear, int year);

//Print Functions
void printShortDate();
void printLongDate();
void printDOY();
};

#endif

Books as Games

Here's an essay I wrote for my folklore class; it was a fluff class but surprisingly fun. Well, enjoy:

Folklore as Presented in Gaming

How does one translate a story from printed paper to an interactive visual experience? Such is the job of many companies hoping to skip the hassle of writing a story for a videogame by using an already written one, though such a choice has its ups and downs. Some of the books we have read this semester would probably make good games, some probably would not; additionally, much of the folklore is easily implementable whether or not the main story of a novel makes for a good game.

To begin with, a good videogame ought to have a goal-oriented plot, where the player understands what he is working towards by at least halfway through the game. Thus, books that have a plot you might call "slice of life" (that is, a story not about swords & sorcery or conspiracy or mystery; a story about regular people) like Their Eyes Were Watching God and Four Souls tend to be difficult to implement into video games. Neither book really has a clear conclusion that you could really call "achieved." At best, one could imagine Their Eyes Were Watching God like a romance game (such as the Japanese eroge Clannad or Air) where the gameplay consists of making choices and attempting to woo one of the three men that Janie had married in the book. Such a game would lose the sense of character development and gain of freedom that is taught via Janie's progression through the three men in the novel, however; furthermore you'd have to design at least six separate endings (success and failure with each romantic endeavour) which, aside from a good ending with Teacake, would have little to do with the original novel. So, Their Eyes Were Watching God would not really fit well on a videogame shelf, in general.

As for Four Souls, it has the same problem as said earlier with not having a clear goal for the player to aim for, though the way Fleur is portrayed is also troublesome. If you have a character that is only ever seen through the eyes of other characters, and her own thoughts and purpose in life are blocked from the reader ... how do you begin to imagine turning her into a playable character? If you were to implement a back-and-forth switching between Nanapush and Fleur, and kept Fleur more as a side character it would be doable I suppose, but I struggle to imagine what kind of game you'd be playing as Fleur. Doing laundry and other chores to get into the good graces of Polly Elizabeth only to suddenly pull a knife on the man of the house in the night hours? I don't think that would really work so well. At least with Nanapush as the protaganist, you could make an adventure game with a lot of item puzzles (setting the snare, gathering materials for medicine) and ending with a set of speech choices (for that last major scene of Nanapush's in the book, where he has to speak before a gathering of his fellow Ojibwe). So, again, not really an easy choice if you were trying to make a game out of a book.

Now that we've looked at two books that are not really all that viable as concepts for videogames, it would be interesting to look at one that is: Haroun and the Sea of Stories. Now here's a book that you could easily imagine as an adventure game or a sidescroller. There's plenty of potential item and conversational puzzles, and the setting is a lot more fantastic and magical. For examples, let's look at the bus station scene (for a conversational puzzle) and the shadow ship scene (for an item puzzle). At the bus station scene in the book, we find Haroun deciding to sit down and watch instead of trying to desperately secure a seat as the other people are trying to do; this nonconformity gets the attention of Butt, who Haroun convinces (could almost call it a bit of trickery with words) to make the race to the valley of K. If we say that the use of a bus as passage to the Valley of K is the objective of our conversational puzzle, we could design a discussion with specific conversation choices you would have to make with Haroun to get Butt to let you onto the bus to the Valley of K. As for the shadow ship scene, in the book Haroun uses an almost-forgotten about bottle of gold wish-water to get rid of all the shadows by wishing for the moon of Kahani to rotate such that the Sun was directly over the spot where the ship was. Therefore, it's easy enough to imagine an item puzzle where you would need to pull the golden wish-water out of your inventory and make a wish. You would then be prompted with a list of choices about what you wanted to wish for. Just to add in some excitement the whole operation would need to be done before shadow priests closed in on you. All that having been said, I think we can conclude Haroun would make for a reasonably good game.

Since we have examined how some books would do as videogames in a general sense, let us look at some of the more specific folklore elements present and how we could turn them into a gameplay element. 'Alchemy' is the usual name for combining items to make a medicine, curse or similar magical object in videogames (some good examples are the Atelier games from Gust or the Kyrandia games). I think we could classify the majority of the folklore activities in Four Souls and Bless Me, Ultima into that category. In Four Souls Nanapush on several occassions and Fleur at least once in the story practice a form of Native American medicinal folklore. Nanapush uses it to make a love potion for himself and Margeret as well as to curse his arch-enemy Shesheeb. Fleur uses it to cure John Mauser. While we don't get a really clear view of what exactly is done we do get the idea that in the first case it is a combination of various items, and in the second that it is something akin to acupuncture or chiropracty. All in all, it'd be relatively easy to implement Nanapush's activities as a kind of 'alchemy' item puzzle. Fleur's chiropracty-like activity ... maybe we could make some kind of gameplay element similar to the Operation! board game.

In Their Eyes Were Watching God there is a folklore activity commonly referred to as "playing the dozens;" basically an insult game, as well as the dice game and references to the "John the Conqueror" and "the town mule" folktales. Insult games are basically conversational puzzles, where you might have a set of responses to choose a reply for a specific insult. The best example I can think of for this is the Monkey Island games from Lucasarts, which is all about pirates and swashbuckling. Instead of a combat system for all the sword-fighting and arm-wrestling and what-not, Lucasarts decided to implement an "insult-fighting" system where you would have to respond to such quips as "You fight like a dairy farmer!" with "only because you're a cow!" So "playing the dozens" is easy enough to implement. The dice game we're not really given a lot of information on, but there are entire videogames all about different ways to play with dice, so it is not all that hard to imagine per se. The allusions made to the various folktales are probably the kind of thing you would implement not really as a major part of the game except in terms of setting, mood, and atmosphere, perhaps leaving hints to other item puzzles in the game by using the folktales; similar to the hints left in a fairytale book as to how to beat the first boss in Silent Hill, or the similar use of a fairytale to explain how to clear an obstacle in Silent Hill 3 when you first enter the Otherworld. Therefore, it is easy to imagine how to implement most of the folklore elements, in and of themselves, into a video game.

In conclusion, videogames are often designed from plots, taken in part or whole, from books. Out of the books we've studied over this semester, it seems fair to say that Four Souls and Their Eyes Were Watching God would not really
make very good videogames due mostly to the way the plot is developed in both books, and somewhat as a result of being "slice of life" types of stories. Haroun on the other hand, has all the basic elements to fit the usual criteria, and is certainly more marketable with its Dr. Seuss-like magical setting. As we examined a few of the more specific elements from the various folklore contained the books, whether it was "playing the dozens" or collecting herbs and making medicines (for good or ill), most of them have already been represented in some fashion in videogames, and as a result it's not hard to imagine how we could interpret an interactive framework to include them in.

Overpopulation Essay

This is a research paper I wrote waaaaay back in my "research paper" class in my Freshman year of college. Enjoy!

14 July 2005
On The Union of Concerned Scientist Warning to the World
Concerning the Threat of Overpopulation

In November of 1992, one thousand seven hundred scientists affiliated with the Union of Concerned Scientists1 signed the “World Scientists’ Warning to Humanity,” which was written by Henry Kendall. In this ‘warning’ Kendall says that:

"Pressures resulting from unrestrained population growth put demands on the natural world that can overwhelm any efforts to achieve a sustainable future. If we are to halt the destruction of our environment, we must accept limits to that growth. A World Bank estimate indicates that world population will not stabilize at less than 12.4 billion, while the United Nations concludes that the eventual total could reach 14 billion, a near tripling of today’s 5.4 billion. But, even at this moment, one person in five lives in absolute poverty without enough to eat, and one in ten suffers serious malnutrition."

How true is this? Is the world really approaching overpopulation? I decided to research the topic and find out, dividing the topic into several basic questions. First, what constitutes overpopulation? Second, is the world facing overpopulation as a problem today? Third, what solutions have been suggested to prevent overpopulation or to at least slow population growth? For those solutions that have already been implemented, what has worked, what has not worked, and why? Lastly, if in actuality population decline is the modern problem (as much of my research has suggested), how did we get there, what problems does it pose, and how do we get back into population growth (if that is needed)? With these questions in mind, I began my research.

What is overpopulation? According to The American Heritage Dictionary of the English Language, it is “The condition of having a population so dense as to cause environmental deterioration, an impaired quality of life, or a population crash.” Kendall and the world scientists seem to agree with this definition. But the problem with this definition is that one can almost say they “feel” the world is overpopulated, or a city is overpopulated, because in their eyes it may fit the aforementioned description. Take, for instance, Salt Lake City. If one is used to a small town atmosphere, the city atmosphere can feel so uncomfortable that it lowers one’s quality of life. The crime rate (especially the murder rate) that naturally rises with the population density might be labeled as a type of population crash. And to top it all off, the air pollution is undoubtedly worse than in places outside the city. So if such conditions are natural for any areas with high population densities (or even medium population densities, such as Salt Lake City), when does one say that there is overpopulation? For my own research, I have decided that severe environmental damage, engendering the over-consumption of resources to the point that the surrounding areas have become barren, and severe changes in quality of life for the residents of an area (such that the majority of people are without food, water, and shelter) are required to call it overpopulation. With this clarification, places like Los Angeles (which I have visited) are not overpopulated because people in those cities have a high quality of life (while there are hungry homeless, they are far from being a majority), the pollution is not so bad as to seriously affect the surrounding environment, and crime is not so bad as to kill a noticeable percentage of those cities’ populations. To call a place overpopulated, then, would require: a) severe negative environmental impact; b) people with little to no quality of life, where any food and shelter is scarce, and quality food and shelter is non-existent; and c) a mass die-off from malnutrition and starvation (death from disease has too many extraneous factors for use as a good criterion).

Now that we have a definition of what overpopulation is, and more importantly, what conditions would exist to suggest overpopulation, is the world overpopulated? Do we have enough resources to support our current world population? Well, from what Tweeten and Zulauf, authors of the Futurist study “Feeding the World: the Long-term Outlook,” say, the world is still harvesting resources, most countries have surpluses of these resources stocked up, and there are more than enough resources to support the current population. Tweeten and Zulauf make this clear when they point out that farms in general are yielding far more per acre now than ever before, even to the point that many plots of farmland are being re-zoned as residential or commercial areas.2

While there are certainly places that have few resources now, such as sub-Saharan Africa, it is not as if they’ve run out of resources. Thomas Sowell, in one of his columns for Townhall.com, makes clear that Africa’s problems are bad leadership, bad geographical location, and bad foreign aid policies from other nations rather than just too many people with too few resources. This is made even clearer when Sowell contrasts the centrally-planned governments of some African nations with the free-market economy of the Ivory Coast. Under then-president Felix Houphouet-Boigny’s democratic government, that country evidently prospered. This shows that overpopulation is, if even a factor, not the decisive factor in causing sub-Saharan Africa’s various problems.

As for environmental problems, who’s to say that the problems we have now, or think we have now, are directly related to overpopulation? I’ve heard lots of arguments by environmentalists that things like deforestation and the loss of species to extinction are caused by rapid human expansion. At the same time, there are many people who I’ve heard claim that the Earth can handle anything that humans do to it, even so far as nuclear winter. And there are, of course, lots of people (myself included) who hold opinions that are somewhere in between. So which argument most accurately describes the state of the environment, and the causes for that state? The main question remains whether or not the environment shows signs of devastation due to human overpopulation. Mark Lynas, in an article for the British magazine New Statesman, claims that because of human overpopulation one fifth of bird species, forty percent of mammals and fish, one third of amphibians, and up to one half of all plant species are threatened with extinction.3 He says, in his title even, that “The Biomass of Human Bodies Now Exceeds by a Hundred Times that of any Large Animal Species that Ever Existed on Land.” So there is a lot of people on the planet Earth, and a lot of lower species are facing extinction. While there is evidence that human encroachment might force certain species’ habitats to be changed (leading to possible extinction), that alone doesn’t show overpopulation. I found nothing in Lynas’ argument that gives evidence of environmental damage due to human overpopulation.

Thus, it can be seen that there is not an overpopulation problem today, but what about the future? The United Nations Population Fund’s most recent studies show that the current world fertility rate4 is about two and nine tenths, and steadily decreasing. According to Micheal Meyer, a two and one tenth fertility rate is required for population stability, so it appears that the world population will soon move into decline. The studies indicate that Europe’s native populations are already in decline, with Italy and Spain leading with a rate of one and two tenths. Those studies also show that France and Ireland have the highest averages in Europe, with a fertility rate of one and eight tenths. They find that Germany’s fertility rate, and the average in Europe, is at one and four tenths.5 Another interesting fact illuminated by the United Nations Population Fund studies is that, along with Europe, all the developed nations in SE Asia as well as China are already in a state of native population decline. Furthermore, it seems that America is the only developed nation with a fertility rate above replacement levels, but it is barely so. The United Nations Population Fund goes on to estimate a worldwide fertility rate drop below two and one tenth by the year two thousand fifty. Even the nations in the Middle East and in sub-Saharan Africa (which currently have rates well above replacement, according to the UNFPA) are expected to have below replacement levels of fertility rates by that time.6

So what, then, are the effects of population decline? According to Meyer and Boorse, those nations whose leaders were misguided enough to start social security programs (or similar policies) will be in for deep economic troubles. Meyer and Boorse say the worst problems will arise in China, which is expected to have the so called ‘4-2-1' situation. That is, four grandparents and two parents dependent on the income of one child. According to Meyer, this problem arises mainly from the population decline (which means less labor available in every generation, leading to less prosperity, leading to less wages), along with bad health policies (which lead to people retiring at a younger age). More importantly, Meyer says, this will force the government to lower whatever benefits are provided by their social security system, or to raise the taxes on the workers, or both.7 The same problem will undoubtedly occur in every country with a social security system or social security-like policies.

But what of the positive effects of population decline? Tweeten and Zulauf suggest that negative population growth (that is, decline) will alleviate any fears of global food crises. All of the sources I’ve read agree that there will be less crowding, greater per capita income, healthier living, and a healthier environment after a population decline.8 Do these outweigh the problems? While it might be good for China if its financial policies force a government collapse (as discussed earlier), recessions and/or depressions rivaling, or even surpassing, that of black Thursday’s are a bleak future to think of. Granted, not every nation will face this (as not all nations have social security or like programs, and there is the possibility that those countries that currently have social security might rid themselves of it, seeing the coming population decline), but for those that will, are the positive effects worth potential economic ruin? What worries me even more is the idea that in this situation, humanity might see the complete loss of one culture or another (which, to me, is worse by far than the extinctions of any animals). Whether the good effects of population decline outweighs the negative effects is something I suppose people will need to consider themselves.

So now we are left with the question: What led to the change of a world worried about overpopulation to a world worried (or relieved) about population decline? And, at the same time, What were the solutions that led to decline? Potts gives the blame (or credit, if you prefer) to the increasing availability of contraceptives. He claims that without the further spread of contraceptives, the fertility rate will not decrease swiftly enough to meet United Nations Population Fund estimates by the year two thousand fifty.9 Interestingly enough, Spain and Italy, which have the lowest fertility rates in Europe, also have majority populations of Roman Catholics, a sect of Christianity that is strongly against any usage of contraceptives.10 So Potts’ thesis that contraceptives are the main force in decreasing worldwide population is questionable. In China, there is the one-child per household policy11, which has undoubtedly cut down on births in that country. Add to that the tradition that Chinese families carry on their name through male children (much the same as many cultures), and you get a lot of families with only one child, and that child is a boy. Thus, the current generation and the next generations of Chinese males will find it very difficult to find a mate. One other factor mentioned by Potts is that richer people tend to want fewer children, for which he gives Bangladesh as an example. Potts says that Bangladesh decreased from a fertility rate of over five to a little above replacement rates in under five years, alongside rapid economic development and the increasing availability of contraceptives. At the same time, however, one can imagine that materialistic philosophies began to take root, and Christian missionaries were given more freedom to evangelize (which has happened in every nations that has ‘westernized’ itself in the past).12 Which particular event (or set of events) caused the decrease in fertility rate is hard to determine. According to Tweeten and Zulauf, a decrease in fertility rate (and thus, a negative population growth) is just one of the things that characterizes a developed nation. Meyer points out that even in developed countries where the government is supporting systems that promote fertility rates (such as Singapore, which has a subsidized dating service), the rates are dropping. Ultimately, the cause of the change from explosive growth to slow decline is probably not contraceptives, but is hard to determine otherwise. China’s one-child policy was definitely a force for that country, but for Europe, America, and developed Asian countries, the decrease in fertility is still, to me, an unanswered question.

In conclusion, overpopulation is not one of the modern world’s problems. The Union of Concerned Scientists was wrong in that, at least. The real issue seems to be negative population growth and the problems it brings with it. Countries with social security will be devastated by the decrease in available labor and the increase in the number of retirees. These governments will face a very real problem unless some major changes are made. On the other hand, population decline will bring some positive effects for the environment, for individuals, and for some economies. It will undoubtedly reduce the output of pollution and the consumption of resources. Land will be freed up so that houses will be cheaper (as mentioned by Nicholson-lord) in general. Some animals that are currently threatened by human encroachment in their environments may possibly return to nominal population levels13. There will be no worries of a food crisis or any sort of famine. Production of agricultural goods might even increase as the population declines. All these things and more good will probably come of the decrease in population. Whether the economic problems discussed earlier will be worth it (for some nations) is not something I can answer.

But what of the policies that caused the change? China’s one-child policy was a factor for that country, without a doubt. The spread of contraceptives is often tied with lowering fertility rates, but is of questionable viability because it in turn raises wanton promiscuity, which in turn raises illegitimacy. Removing the responsibilities attendant with intercourse is simply an unwise decision no matter how you look at it. Perhaps it’s as Tweeten and Zulauf claim, that population decline is simply a sign of development? If that is the reason, there is an uncountable number of causes for the effect of population decline. Among them may very well be contraceptives, certain religions and philosophies, even prosperity might be a cause. I can’t really point out a definitive reason why populations have started to decline, but I suppose that’s not really what’s important. What’s important is that the UCS’ “World Scientists’ Warning to Humanity” was wrong, and instead of considering solutions to population growth, humanity should now start looking for solutions to a completely opposite concern: population decline.









Notes
1 The Union of Concerned Scientists, from what I can determine from their website, is an organization that’s been around since the seventies, based at MIT. It tends to be slanted toward environmentalism, but the argumentation it uses tends to be well sourced, if not entirely logical (to a conservationist like me, anyway). One of the problems it has, especially with the “World Scientists’ Warning to Humanity” is that it boasts several Nobel laureates among its body, which adds precisely nothing for its credibility, considering the amount of politics involved in the awarding of Nobel Prizes. Though it may be off-topic, it is notable that Zork, a landmark in computer gaming history, was developed by students at MIT, so I tend to like that particular institution.

2 This is undoubtedly an unwise move. In my own valley, while there is certainly a lot of fertile land that has yet to be used for farming, there is even more land that has the qualities most people look for when they want to build a home (a nice view, clean air, etc, etc) in areas that are not so apt for agricultural uses.

3 What Lynas fails to mention is which animals are threatened, and where he gets that information. He doesn’t even provide any evidence that it was humanity that caused those species to become threatened with extinction. Furthermore, the fact that his whole argument is heavily based on evolutionary theory lends very little credibility. Of course, me being a Christian, and creation being the most logical explanation I can find, using evolutionary theory for reasoning purposes would lend little or no credibility to an argument, at least for me anyway.

4 Fertility rate is based on how many children born per woman in a country. So for Sanpete County (where I live), with its average of five to six children per mother, the fertility rate would be about 5.5.

5 All these rates are originally from studies of the United Nations Population Fund, and are mentioned by Tweeten & Zulauf, Potts, Boorse, Nicholson-Lord, and Meyer.

6 According to Potts’ article in Scientific American, this estimate assumes that developed countries will continue to pay for undeveloped and developing countries’ contraceptives. This despite the fact that, logically, contraceptives in general tend to encourage promiscuity. This is in turn results in higher fertility rates. Furthermore, while the ability to perform abortions might result in lower populations (mainly because abortion often kills the mother along with the child, either at the time of surgery, or from complications; especially when you consider that in undeveloped/developing countries, quality surgeons are not exactly in high supply), birth control pills and injections only guarantee that if there is a resultant child it will be defective in some way or another. And it is very seldom that a mother that knows the risks involved in an abortion (which are multiplied by being in a undeveloped/developing area) will have an abortion anyway. (Please make note that this argument is my own reasoning, based on my personal observance of teenagers at a public high school I attended a few years ago, as well as studies and things that pop up in the news every so often and become something like common knowledge).

7 This may actually be, in my humble opinion, a good thing, not only for China, but for the rest of the world. It may end up getting rid of social security forever. If humanity is really lucky, it may end all of the ineffective government entitlement programs. Unfortunately, my experience suggests that even given the obvious failures of those programs as of yet, many politicians are completely oblivious to the idea of getting rid of them. Furthermore, it is probable that they will continue to ignore the problem even after it completely destroys the economy, blaming the economic devastation on something else.

8 Nicholson-Lord especially extols the increasing availability of a home with a view.

9 Potts is an obstetrician by profession so it is expected that he would extol the usage of contraceptives.

10 I know this because I remember reading it somewhere, though I can’t pinpoint exactly where I read it. Should be common knowledge, assuming everyone remembers their high-school history courses.

11 This policy, which you can google if you wish, basically makes it so that every family in China can have one and only one child. If they want more, they have to fill out several papers to get approval, and approval is not given to very many. Being a major violation of human rights, it is a controversial policy that is often discussed on TV, the internet, and in periodicals (which is where I get my information, though I am regrettably unable to pinpoint any specific sources).

12 For example, when Japan started to westernize, the people that came to teach them were Jesuits (again, this should be common knowledge to anyone who attended high school World History).

13 Again, Mark Lynas never did give specific info to relate the decrease in the number of particular species to overpopulation. He didn’t really prove, per se, that it was even human encroachment, but we can probably assume that human encroachment is at least one of the factors.










Works Cited
Borse, Dorothy. “Overpopulation: Ecological & Biblical Principles Concerning Limitation.” Worldviews: Environment Culture Religion. 7.05 (2003): 154-170.
Kendall, Henry. “World Scientists’ Warning to Humanity.” Union of Concerned Scientists. 29 Oct. 2002. Union of Concerned Scientists. 8 July 2005 .
Lynas, Mark. “The Biomass of Human Bodies Now Exceeds by a Hundred Times that of any Large Animal Species that Ever Existed on Land.” New Statesman 23 Feb. 2004: 23-25.
Meyer, Micheal. “Birth Dearth.” Newsweek 27 Sept. 2005. 8 July 2005 .
Nicholson-Lord, David. “The Fewer the Better.” New Statesman 8 Nov. 2004: 24-26.
“Overpopulation.” The American Heritage Dictionary of the English Language. 4th ed. New York: Houghton Mifflin Company, 2000.
Potts, Malcom. “The Unmet Need for Family Planning.” Scientific American 282.1 (2000): 88-93. Vocational and Career Coalition. 8 July 2005 .
Sowell, Thomas. “The Tragedy of Africa.” Townhall.com Ed. Johnathon Garthwaite et al. 12 July 2005. Townhall.com. 13 July 2005 .
Tweeten, Luther and Carl Zulauf. “Feeding the World: the Long-term Outlook.” Futurist Sep. 2002: 54-59.
United Nations Population Fund. July 2005. United Nations Population Fund. 8 July 2005 .

Update: Wow that did not copy and paste as well as I thought. Edited for better white spacing and line breaking.

Concurrency ~ Starving Philosophers Problem

This site is awesome!

Did you know...

...about a guy named Koizumi Junichiro? Just started reading a ... mahjong manga based on Koizumi (who was the Japanese prime minister ). Interesting stuff, and an interesting look at this particular mangaka's viewpoint on US Presidents George HW Bush and George W Bush (in that W is shown as something of a Momma's boy, where HW is shown as being pretty strong-willed, a complete reverse of the usual characterizations). I wonder if most Japanese look at W like that?

My roommate, who is a Japanese national, holds a pretty negative view of extensive use of American military force of late, noting something that I didn't even think about: Japan's funding the American military. Not solely, of course, but I didn't realize that there are still funds going from Japanese taxpayers to American forces. I'd be pretty interested in finding out more about how that works, exactly, but as it is it seems rather unethical. I mean, I know American forces provide a certain amount of security and protection by staying in the area (especially what with recent off-shore oil issues between Japan, China and Korea) but us charging for it does seem a little...off.

Anyways, back to Koizumi, from the sounds of it he's a world leader in the same league as Reagan and Thatcher, and it's saddenning that his faction of the LDP lost power within a few years after he passed leadership on, and the LDP as a whole has now lost power to the Democratic Party in Japan. And, while I need to do more reading to be sure, it sounds like the leadership of the Democratic Party of Japan are essentially the descendants of the zaibatsu, the nobility-turned-'businessmen' that became dominant and powerful in Japan much like the Rockefeller-type families and their "Business Trusts" in the late 1800s and early 1900s here in the US. Which is to say, the DPJ seems like a pretty corrupt group.

A Beginning ~ Random Meanderings

Hello world.

So, just thought, all the cool kids are writing blogs these days, I should too. I'm thinking I'll write about computer science stuff here, my own personal philosophy, political leanings, and my own game reviews (or at least, partial reviews in that I don't always play a game through to the end).

I'm also going to post some of my essays I think are noteworthy up here for your entertainment, maybe expanding on some of the ideas more later on. I'm also gonna toss up some example programs I write for my own reference (and anyone else who finds them interesting).