Friday, November 07, 2008

OU (MW): Working from back to front

Having decided upon a content layout I have started to think about the various bits of code of will need for each area.  After sometime contemplating how all these bits of code should fit together to form the final program I decided that perhaps a better approach would be to create the final program first and then I can use elements of this code with my core text to demonstrate certain aspects, for example the default constructor.  My program is now complete and it demonstrates a default constructor, constructors with arguments and the 2 ways of using the this keyword, by producing multiple instances of my Frog class.  Now to get on with the text.

The code:

void setup() {
size(640, 480);
background(255, 248, 220);
smooth();
noLoop();
}

void draw() {
Frog freddo;

for (int i = 0; i < 75; i++) {
switch (int(random(0, 6)+1)) {
case 1:
freddo = new Frog();
break;
case 2:
freddo = new Frog(int(random(52, 588)+1),
int(random(37, 442)+1));
break;
case 3:
freddo = new Frog(int(random(0, 254)+1),
int(random(0, 254)+1),
int(random(0, 254)+1));
break;
default:
freddo = new Frog(int(random(52, 588)+1),
int(random(37, 442)+1),
int(random(0, 254)+1),
int(random(0, 254)+1),
int(random(0, 254)+1));
break;
}
freddo.display();
}
}

class Frog {
// properties
int xPos;
int yPos;
int redColBody;
int grnColBody;
int bluColBody;

// constructors
// default constructor
Frog() {
this(320, 240, 0, 128, 0);
}

// constructor (position)
Frog(int xPos, int yPos) {
this(xPos, yPos, 244, 164, 96);
}

// constructor (coloured body)
Frog(int redColBody, int grnColBody, int bluColBody) {
this(320, 240,redColBody, grnColBody, bluColBody);
}

// constructor (position & coloured body)
Frog(int xPos, int yPos, int redColBody, int grnColBody,
int bluColBody) {
this.xPos = xPos;
this.yPos = yPos;
this.redColBody = redColBody;
this.grnColBody = grnColBody;
this.bluColBody = bluColBody;
}

// methods
void display() {
stroke(0);
strokeWeight(1);
// body
fill(redColBody, grnColBody, bluColBody);
ellipse(xPos, yPos, 90, 45);
// feet
fill(107, 142, 35);
ellipse(xPos - 30, yPos + 15, 45, 23);
ellipse(xPos + 30, yPos + 15, 45, 23);
// eyes
fill(255, 255, 255);
ellipse(xPos - 15, yPos - 23, 23, 30);
ellipse(xPos + 15, yPos - 23, 23, 30);
fill(0, 0, 0);
ellipse(xPos - 15, yPos - 23, 8, 8);
ellipse(xPos + 15, yPos - 23, 8, 8);
// mouth
noFill();
strokeWeight(2);
arc(xPos, yPos - 2, 30, 5, 0, PI);
}
}


The output:

image

Thursday, November 06, 2008

OU (MW): Welcome back old friend

Part of the criteria for my chunk (like a majority of all the chunks) is to develop a progam to demonstrate what I have written about and to try and get it to do something graphical.  Thus I have been musing over the last couple of days as to what graphically I can do to demonstrate the use of constructors.  I do not want to do anything that is too complicated as I don't want it to detract from the main point of the code, but I do want to make it interesting and perhaps fun.

Well last night I decide to welcome back on old friend from the time I studied M206.  For this course we were taught all about OOP's via the use of frogs.  These weren't just normal frogs, there was also HooverFrogs, DietingFrogs, frogs that could barn dance and toads.  So let me introduce Freddo (for those who remember the chocolate bar).

image         
     My Freddo                    The real Freddo

I will now be able to demonstrate different constructors, creating Freddo's in different places on the screen and in different colours

M450: Cinders is not going to the ball

This morning I received an e-mail concerning my application for one of the two places at the Computer Science 2008 conference.  Unfortunately due to the number of applicants and the "high quality of all the projects" I was not selected, though the feedback was positive and I am now really intrigued as to what final grade I am going to achieve for my project.

However, the selection panel agreed that your project was highly commendable and you will be receiving a letter of commendation in recognition of this from the M450 course chair.

OU (MW): Content layout

Prof. Ince has confirmed that I can do chunk 62 "Constructors", so I have been working on what content to include and how to lay it out.  This is what I have decided on:

  • Introduction
    - What has been covered so far
    - What are constructors?
  • Default Constructors
    - Hidden
    - User specified
  • Overloading Constructors
    - Arguments and setting instance properties
    - the this keyword (part 1) - setting instance properties
  • Advanced Constructors
    - Argument checking
    - The this keyword (part 2) - invoking a constructor
  • Summary
  • Program putting all the ideas togeather

Tuesday, November 04, 2008

OU (MW): Committed

Having read chapters 1 & 3 of Processing: Creative Coding and Computational Art I decided upon committing to chunk 15 "Functions 2".  I e-mail'd Prof. Ince with my decision and then started to think about a layout for the chunk.

Purely by chance I discovered that someone else has already committed to chunk 15, so I have had to revisit my list of candidate chunks and upon deciding a replacement I e-mail'd Prof. Ince with my new choice.

My chunk of choice is now chunk 62 "Constructors".  Tonight I will read through pages 309 -311 of the book, and also dig out the corresponding section(s) from the course text for M254 - Java Everywhere that I took back in 2005 as it might prove useful.

OU (MW): To do list

A simple to do list so I know what is outstanding.

  • Decide to participate of not. Done
  • Read the introduction to Processing. Done
  • Read the wiki entry on "Blog".  Not required
  • Send email giving details about myself and willingness to participate. Done
  • Set up a blog. Done
  • Decide on what chunk to write. Done (04.11.08)
  • Email details of the chunk I want to write. Done (04.11.08)
  • Download and install the Processing IDE. Done (28.10.08)
  • Order the Processing book. Done (28.10.08)
  • Read chapters 1 and 3 of the book. Done (04.11.08)
  • Write the chunk.
  • Email the finished chunk.

Notes:

  • The book to order:
    Processing: Creative Coding and Computational Art (Foundation)
    Ira Greenberg
    ISBN: 9781590596173
    at Waterstones

Monday, November 03, 2008

OU (MW): Google Reader

Apart from keeping an eye on everyone's blogs by using Feedreader, I have clumped them altogether within Google Reader (see here: MassWriting) and added them to my blog as a widget.

M450: Gobsmacked!!!

I received an e-mail last week from a lecturer in the Department of Computing at the OU asking if I was interested in applying for one of the two places, in the form of bursaries, at the Computer Science 2008 conference in December.  This all sounded very interesting and I replied saying that I would be interested in attending.  Yet the part of the e-mail that really surprised me was...

...your name was put forward as a potential candidate by the M450 course team who were very impressed with quality of your undergraduate project work.

Considering how I felt about the project and what I had produced, I was really gobsmacked when reading the above comment.  Still I must not get me hopes up to high with regards to my final result for M450.  Only 39 more days until the results are supposed to be available.

OU (MW): Book and Chunks

This morning I received my copy of Processing: Creative Coding and Computational Art (ordered via Amazon), so now to start reading.  I will start with chapters 1 & 3, as recommended by Prof. Ince, and then move onto the sections in the book corresponding to the candidate chunks that I have identified whilst trying to decide for which one I should write.

I went through the complete list of chunks, last week, and from each block of ten chunks identifying at least one that is of particular interest. I ended up with a list of eight candidate chunks and from there I eliminated half of them.  The plan now, after reading the corresponding sections from the book, is to prioritise the remaining 4 candidates and e-mail Prof. Ince with my choice.

Note:  Someone else has already chosen one of the chunks that I have in my candidate list, thus I am now down to three candidates.

Note:  Having done a brief skim through the book, I am intrigued as to why we don't have to read chapter 2.  Might have to e-mail Prof. Ince to enquire as to why.

Wednesday, October 29, 2008

OU (MW): Processing - A Bug!

Yesterday I downloaded and installed Processing.  I then started going through the "Getting Started" page of the processing.org web site and everything seemed to be going ok.  That is until I went to save same code.  It just would not save.  Every time I tried, the IDE kept responding with the message "Save Canceled".

image

I had a look around the web site and found that this is a known bug and was reported on the 27.Oct.08.

This morning I discovered the exact nature of the bug.  If when saving a new sketch you accept the default supplied filename (i.e. sketch_081029a) the save will be cancelled.  The work around is to overwrite the filename given in the "File name:" field, of the "Save sketch folder as..." dialogue box, with a filename of your choice.

Monday, October 27, 2008

M450: Course result available on...

Saw this on my StudentHome page yesterday...

image

OU (MW): Up the garden path

Simon K. left an interesting comment on my previous posting "OU: Mass Writing", and after re-reading the posting I realised that I might have mislead people with what I have written.  Prof. Ince in his blog gives a better description of what the book is about.

The book writing project involves OU students, and anyone else who wants to volunteer, writing a book about the Java-based computer-art system known as Processing.

Once completed the book might be considered for use within a course, and if accepted for publication by a conventional publisher...

the royalties will go to the student hardship fund or any other charitable fund in the Open University

Thursday, October 23, 2008

OU: Mass Writing

Received an e-mail this morning from a Professor Ince, the Head of Computing dept. at the OU, asking if I would like to collaborate on a book about Computer Art.  Sounds grander than it probably is.  The department actually is looking for 85 volunteers, with each volunteer completing a section comprising of 2,500 words and a computer program.  I have decided to volunteer as it looks as though it could be fun.

For further details take a look at page 5 of the Autumn issue of Sesame.

Tuesday, October 21, 2008

Somebody with to much time on their hands

I know these are old but they are still entertaining...

The OU has caught a cold

It is not only county and borough councils that have been caught out by the collapse of several Icelandic banks.  It now appears that a number of UK universities have also caught a cold, including the Open University.

The Open University said it had invested £6.5m in UK subsidiaries with the Icelandic banks.

"The funds at risk with these two banks, although significant, represent less than 4% of the university's cash holdings and 1.5% of the university's expenditure budget this year.

"There is no threat to the university's operations and staff and suppliers will be paid as normal," said vice-chancellor Professor Brenda Gourley.

This really begs the question "What was so special about these banks to entice so many high profile depositors?"

ref: BBC News

Friday, October 17, 2008

M366: In conversation with... a computer program

ref:  BBC News

Stuck for someone to talk to? Elbot is a computer program pretending to be a person. And this week it won a prize for coming closest to fooling people into thinking it was human. The BBC's Mark Lobel catches him in a more relaxed moment. 
 

No computer has ever passed the Turing Test to see if, during text-based conversation, a machine can be indistinguishable from a person. But Elbot just came pretty close.
 

At the 18th Loebner Prize for artificial intelligence, held at the weekend, this artificial intelligence entity convinced four of the 12 human interrogators he was indistinguishable from them.
 

If Elbot had convinced one other, it would have passed the magic 30% mark - the threshold set by Britain's most famous code-breaker, Alan Turing, who devised the test back in 1950.

What's more Elbot, the very same version that came so close to passing itself off as a living, breathing, sentient human being (under Turing's rules at least), is online - for anyone to talk to. Let's see if he's feeling chatty. [...]

Tuesday, October 14, 2008

M366: Test explores if robots can think

Reported on the BBC's news web site:

Scientists at the University of Reading tested five machines to see if they could pass themselves off as humans in text-based conversations with people.

The test was devised in 1950 by British Mathematician Alan Turing, who said that if a machine was indistinguishable from a human, then it was "thinking".

http://news.bbc.co.uk/1/hi/technology/7666836.stm

Thursday, October 09, 2008

Do you duty!

Keep things safe

Since starting my OU studies one of my primary concerns has been making sure I have adequate backups of all my OU data.  This is especially relevant to the current course being studied and the TMA being worked on.  There can be nothing more frustrating and depressing than loosing a TMA that is 90% complete and having to recreate it from scratch.  Data loss can come in many guises, such as hard disk failure; loosing a memory stick; corrupt file, and with this in mind I always have 3 copies available at any one time.  One on my home PC, one on my laptop and one on my work PC.  This sounds nice and secure but the problem has been in keeping the 3 machines synchronised.

Over the last few years I have tried various methods including manual copying and trials of commercial packages (i.e. Handy Backup).  Well today I have come across an Open Source program, Synkron, that looks as though it will do the job.

It has a number of features, including:

  • Synchronise multiple folders
  • Tabs allow you to have more synchronisations running at once
  • Periodical synchronisations automatically sync your folders in selected intervals
  • Restore files, which were overwritten during the synchronisation
  • Add files and folders to black list to make sure they won't be synchronised in the future
  • Make schedules and backup using multisync
  • Propagate deletions

With multiple supported platforms:

  • Apple Mac OS X (Universal)
  • Microsoft Windows (Installer)
  • Linux/Unix (Source code, RPM, Ubuntu, Archlinux and ALT Linux packages)

The one drawback is the lack of documentation, although there is a support forum.  Even so it is a simple program to use and I would recommend taking a look at it if you are wanting a way of synchronising data.