by Paul Curzon and Peter W. McOwan, Queen Mary University of London
Revised from TLC blog and the cs4fn archive.
Strictly Come Dancing, has been popular for a long time. It’s not just the celebs, the pros, or the dancing that make it must see TV – it’s having the right mix of personalities in the judges too. Craig Revel Horwood has made a career of being rude, if always fair. By contrast, Darcey Bussell was always far more supportive. Bruno Tonioli is supportive but always excited. Len Goodman was similarly supportive but calm. Shirley Ballas aims for supportive but strict while Motsi Mabuse was always supportive and enthusiastic. It’s often the tension between the judges that makes good TV (remember those looks that Darcy always gave Craig, never mind when they started actually arguing). However, if you believe Dr Who, the future of judges will be robots like AnneDroid in the space-age version of The Weakest Link…let’s look at the Bot future. How might you go about designing computer judges, and how might objects help?
Write the code
We need to write a program. We will use a pseudocode (a mix of code and English) here rather than any particular programming language to make things easier to follow.
The first thing to realise is we don’t want to have to program each judge separately. That would mean describing the rules for every new judge from scratch each time they swap. We want to do as little as possible to describe each new one. Judges have a lot in common so we want to pull out those common patterns and code them up just once.
What makes a judge?
First let’s describe a basic judge. We will create a plan, a bit like an architect’s plan of a building. Programmers call these a ‘class’. The thing to realise about classes is that a class for a Judge is NOT the code of any actual working judge just the code of how to create one: a blueprint. This blueprint can be used to build as many individual judges as you need.
What’s the X-factor that makes a judge a judge? First we need to decide on some basic properties or attributes of judges. We can make a list of them, and what the possibilities for each are. The things common to all judges is they have names, personalities and they make judgements on people. Let’s simply say a judge’s personality can be either supportive or rude, and their judgements are just marks out of 10 for whoever they last watched.
Name : String CharacterTrait : SUPPORTIVE, RUDE Judgement : 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
We have just created some new ‘types’ in programming terminology. A type is just a grouping of values. The type CharacterTrait has two values possible (SUPPORTIVE or RUDE), whereas the type Judgement has 10 possible values. We also used one common, existing type: String. Strings are just sequences of letters, numbers or symbols, so we are saying something of type Name is any such sequence. (This allows both for futuristic judges and for hip hop and rapper judges- perhaps one day, in retirement C3P0 will become a judge, but also for the likes of 50 Cent one day to become one.)
Let’s start to describe Judges as people with a name, personality and capable of thinking of a mark.
DESCRIPTION OF A Judge: Name name CharacterTrait personality Judgement mark
This says that each judge will be described by three variables, one called name, one called personality and one called mark. This kind of variable is called an instance variable – because each judge we create from this blueprint will have their own copy, or instance, of the instance variables that describes that judge. So we might originally have created a Len judge and so on, but many series later find we need Mostsi one and then an Anton one. Each new judge needs their own copies of the variables that describe them.
All we are saying here in the class (the blueprint) is whenever we create a Judge it will have a name, a personal character (it will be either RUDE or SUPPORTIVE) and a potential mark.
For any given judge we will always refer tco their name using variable name and their character trait using variable personality. Each new judge will also have a current judgement, which we will refer to as mark: a number between 1 and 10. Notice we use the types we created, Name, Character and Judgment to specify the possible values each of these variables can hold.
We are now able to say in our judge blueprint, our class, whether a judge is rude or supportive, but we haven’t actually said what that means. We need to set out the actual behaviours associated with being rude and supportive. We will do this here in a fairly simple way, just to illustrate. Let’s assume that the personality shows in the things they say when they give their judgement. A rude judge will say “It was a disaster” unless they are awarding a mark above 8/10. For high marks they will grudgingly say “You were ok I suppose”. We translate this into commands of how to give a judgment.
IF (personality IS RUDE) AND (mark <= 8) THEN SAY “It was a disaster” IF (personality IS RUDE) AND (mark > 8) THEN SAY “You were ok I suppose”
It would be easy for us to give them lots more things to choose to say in a similar way, it’s just more rules. We can do a similar thing for a supportive judge. They will say “You were stunning” if they award more than 5 out of 10 and otherwise say “You tried really hard”.
TO GiveJudgement: IF (personality IS RUDE) AND (mark <= 8) THEN SAY “It was a disaster” IF (personality IS RUDE) AND (mark > 8) THEN SAY “You were ok I suppose” IF (personality IS SUPPORTIVE) AND (mark > 5) THEN SAY “You were stunning” IF (personality IS SUPPORTIVE) AND (mark <= 5) THEN SAY “You tried hard”
A ten from Len
The other thing that judges do is actually come up with their judgement, their mark. For real judges it would be based on rules about what they saw – a lack of pointed toes pulls it down, lots of wiggle at the right times pushes it up… We will assume, to keep it simple here, that they actually just think of a random number – essentially throw a 10 sided dice under the desk with numbers 1-10 on!
TO MakeJudgement: mark = RANDOM (1 TO 10)
Finally, judges can reveal their mark.
TO RevealMark: SAY mark
Notice this doesn’t mean they say the word “mark”. mark is a variable so this means say whatever is currently stored in that judge’s mark.
Putting that all together to make our full judge class we get:
DESCRIPTION OF A Judge: Name name CharacterTrait personality Judgement mark TO GiveJudgement: IF (personality IS RUDE) AND (mark <= 8) THEN SAY “It was a disaster” IF (personality IS RUDE) AND (mark > 8) THEN SAY “You were ok I suppose IF (personality IS SUPPORTIVE) AND (mark > 5) THEN SAY “You were stunning” IF (personality IS SUPPORTIVE) AND (mark <= 5) THEN SAY “You tried hard” TO MakeJudgement: mark = RANDOM (1 TO 10) TO RevealMark SAY mark
What is a class?
So what is a class? A class says how to build an object. It defines properties or attributes (like name, personality and current mark) but it also defines behaviours: it can speak, it can make a judgement and it can reveal the current mark. These behaviours are defined by methods – mini-programs that specify how any Judge should behave. Our class says that each Judge will have its own set of the methods that use that Judge’s own instance variables to store its properties and decide what to do.
So a class is a blueprint that tells us how to make particular things: objects. It defines their instance variables – what the state of each judge consists of and some rules to apply in particular situations. We have so far made a class definition for making Judges. It is important to realise that we haven’t made any actual objects (no actual judge) so far though – defining a class does not in itself give you any actual objects – no actual Judges (no Bruno, no Motsi, …) exist to judge anything yet. We need to write specific commands to create them as we will see.
We can store away our blueprint and just pull it out to make use of it when we need to create some actual judges (eg once a year in the summer when this year’s judges are announced).
Kind words for our contestants?
Suppose Strictly is starting up (as it is as I write, but let’s suppose all the judges will be androids this year) so we want to create some judges, starting with a rude judge, called Craig Devil Droidwood. We can use our class as the blueprint to do so. We need to say what its personality is (Judges just think of a mark when they actually see an act so we don’t have to give a mark now.)
CraigDevilDroidwood IS A NEW Judge WITH name “Craig Devil Droidwood” AND personality RUDE
This creates a new judge called Craig Devil Droidwood and makes it Rude. We have instantiated the class to give a Judge object. We store this object in a variable called CraigDevilDroidwood.
For a supportive judge that we decide to call Len Goodroid we would just say (instantiating the class in a different way):
LenGoodroid IS A NEW Judge WITH name “Len Goodroid” AND personality SUPPORTIVE
Another supportive judge DarC3PO BussL would be created with
DarC3POBussL IS A NEW Judge WITH name “DarC3PO BussL” AND personality SUPPORTIVE
Whereas in the class we are describing a blueprint to use to create a Judge, here we are actually using that blueprint and making different Judges from it. So this way we can quickly and easily make new judge clones without copying out all the description again. These commands executed at the start of our program (and TV programme) actually create the objects. They create instances of class Judge, which just means they create actual virtual judges with their own name and personality. They also each have their own copy of the rules for the behaviour of judges.
Once actual judges are created, they can execute commands to start the judging. First the program tells them to make judgements using their judgement method. We execute the MakeJudgement method associated with each separate judge object in turn. Each has the same instructions but those instructions work on the particular judges instance variables, so do different things.
EXECUTE MakeJudgement OF CraigDevilDroidwood EXECUTE MakeJudgement OF DarC3POBussL EXECUTE MakeJudgement OF LenGoodroid
Then the program has commands telling them to say what they think,
EXECUTE GiveJudgement OF CraigDevilDroidwood EXECUTE GiveJudgement OF DarC3POBussL EXECUTE GiveJudgement OF LenGoodroid
and finally give their mark.
EXECUTE RevealMark OF CraigDevilDroidwood EXECUTE RevealMark OF DarC3POBussL EXECUTE RevealMark OF LenGoodroid
In our actual program this would sit in a loop so our program might be something like:
CraigDevilDroidwood IS A NEW Judge WITH name “Craig Devil Droidwood” AND personality RUDE DarC3POBussL IS A NEW Judge WITH name “DarC3PO BussL” AND personality SUPPORTIVE LenGoodroid IS A NEW Judge WITH name “Len Goodroid” AND personality SUPPORTIVE FOR EACH contestant DO THE FOLLOWING EXECUTE MakeJudgement OF CraigDevilDroidwood EXECUTE MakeJudgement OF DarC3POBussL EXECUTE MakeJudgement OF LenGoodroid EXECUTE GiveJudgement OF CraigDevilDroidwood EXECUTE GiveJudgement OF DarC3POBussL EXECUTE GiveJudgement OF LenGoodroid EXECUTE RevealMark OF CraigDevilDroidwood EXECUTE RevealMark OF DarC3POBussL EXECUTE RevealMark OF LenGoodroid
So we can now create judges to our heart’s content, fixing their personalities and putting the words in their mouths based on our single description of what a Judge is. Of course our behaviours so far are simple. We really want to add more kinds of personality like strict judges (Shirley) and excited ones (Bruno). Ideally we want to be able to do different combinations making perhaps excited rude judges as well as excited supportive ones. This really just takes more rules.
A classless society?
Computer Scientists are lazy beings – if they can find a way to do something that involves less work, they do it, allowing them to stay in bed longer. The idea we have been using to save work here is just that of describing classes of things and their properties and behaviour. Scientists have been doing a similar thing for a long time:
Birds have feathers (a property) and lay eggs (a behaviour).
Spiders have eight legs (a property) and make silk (a behaviour)
We can say something is a particular instance of a class of thing and that tells us a lot about it without having to spell it all out each time, even for fictional things: eg Hedwig is a bird (so feathers and eggs). Charlotte is a spider (so legs and silk). The class is capturing the common patterns behind the things we are describing. The difference when Computer Scientists write them is because they are programs they can then come alive!
We have specified what it means to be a robotic judge and we’ve only had to specify the basics of Judgeness once to do it. That means that if we decide to change anything in the basic judge (like giving them a better way to come up with a mark than doing it randomly or having them choose things to say from a big database of supportive or rude comments) changing it in the plan will apply to all the judges of whatever kind. That is one of the most powerful reasons for programming in this way.
We could create robot performers in a similar way (after all don’t all the winners seem to merge into one in the long run?). We would then also have to write some instructions about how to work out who won – does the audience have a vote? How many get knocked out each week? … and so on.
Of course we’ve not written a full program, even for judges, just sketched a program in pseudocode. The next step is to convert this into a program in an object-oriented programming language like Python or Java. Is that hard? Why not give it a try and judge for yourself?
More on …
Related Magazines …
This blog is funded through EPSRC grant EP/W033615/1.