Oh, the robot arm is mostly built, by the way. Whether it will work or not remains to be seen.I like to play around with technology. I try out ideas and see if I can work out how to do interesting things. This is what I'm doing now.
Thursday, 25 October 2012
Game avoidance
I'm on holiday, which used to mean I had long, lazy days entirely at my disposal, unfettered by the need to offer entertainment, sustenance and attention to my delightful children. Not any more. When I am off school, so are my kids. Work just becomes a different type of work, albeit one with people you love.
This week, however, I enjoy the benefits of working at a school whose half-term holidays are out of sync with my kids' school. I can drop them off and then spend six hours doing whatever the hell I want. I could go for a walk, read a book, watch a film, or play one of my many games that are piled up in a sort of entertainment "in-tray". X-Com is my current nemesis and I have to say it is kicking my ass at every encounter.
But this morning was different. I got an email asking me to look at something for work: a new feature for the music database website. It's not something I have to do, as I stopped officially supporting that thing ages ago, but still I find myself drawn back to it, like how George Lucas won't stop meddling with Star Wars until he has annoyed everyone in the universe. (Don't go away thinking I am equating my music database to Star Wars. I'm not. My music database is way less entertaining than Episodes 4, 5 and 6, and only slightly more interesting than Episodes 1, 2 and 3)
.
The thing is, the work was interesting, and involved learning how to do something I didn't know before. I decided to use it to teach myself a bit of Ajax, which is a programming technique rather than a cleaning product, and to play around with my new local PHP testing server. Tinkering is fun and, in many ways, it IS a game. You have a goal (get the thing working), obstacles to overcome (things don't work so you have to find out where they are going wrong) and rewards (the satisfied feeling that you are making progress, both in the project and in your own knowledge). I certainly find it less frustrating than X-Com, because I'm pretty sure my Music Database is not out to get me, whereas those aliens definitely are. The green-blooded bastards.
This week, however, I enjoy the benefits of working at a school whose half-term holidays are out of sync with my kids' school. I can drop them off and then spend six hours doing whatever the hell I want. I could go for a walk, read a book, watch a film, or play one of my many games that are piled up in a sort of entertainment "in-tray". X-Com is my current nemesis and I have to say it is kicking my ass at every encounter.
But this morning was different. I got an email asking me to look at something for work: a new feature for the music database website. It's not something I have to do, as I stopped officially supporting that thing ages ago, but still I find myself drawn back to it, like how George Lucas won't stop meddling with Star Wars until he has annoyed everyone in the universe. (Don't go away thinking I am equating my music database to Star Wars. I'm not. My music database is way less entertaining than Episodes 4, 5 and 6, and only slightly more interesting than Episodes 1, 2 and 3)
.
The thing is, the work was interesting, and involved learning how to do something I didn't know before. I decided to use it to teach myself a bit of Ajax, which is a programming technique rather than a cleaning product, and to play around with my new local PHP testing server. Tinkering is fun and, in many ways, it IS a game. You have a goal (get the thing working), obstacles to overcome (things don't work so you have to find out where they are going wrong) and rewards (the satisfied feeling that you are making progress, both in the project and in your own knowledge). I certainly find it less frustrating than X-Com, because I'm pretty sure my Music Database is not out to get me, whereas those aliens definitely are. The green-blooded bastards.
Thursday, 18 October 2012
Nocturnal Noughts And Crosses
Last night I woke up at 3am with my brain buzzing. Maybe it was because I had gone to bed early, but I could not stop thinking about a cool new project.
"What if," I imagined, "I got a robot arm and taught it how to play noughts and crosses? That would be good on Open Morning at school, and maybe the A level kids would get a kick out of tinkering with it."
I picture a large sheet of paper with a grid on it, a pupil drawing noughts with a thick marker pen, and a computer watching it with a camera before making its own move.
So, as I couldn't sleep I started googling and found one of these cheap robot arms from Maplin. It seems that some people have worked out how to program them in Python, and it doesn't look too tricky. In theory, making an arm draw a cross on a page should be manageable, and if it has trouble handling a pen then it could at least pick up and move a cross-shaped object on a table.
The trickier bit would be making the computer aware of what was happening. I think it's possible to get Python to read an image from a webcam, and it should be possible to write a piece of code to look for a circle drawn on the page.
So that should keep me occupied for a while. I bought the arm today. I'll report back when I have some news.
"What if," I imagined, "I got a robot arm and taught it how to play noughts and crosses? That would be good on Open Morning at school, and maybe the A level kids would get a kick out of tinkering with it."
I picture a large sheet of paper with a grid on it, a pupil drawing noughts with a thick marker pen, and a computer watching it with a camera before making its own move.
So, as I couldn't sleep I started googling and found one of these cheap robot arms from Maplin. It seems that some people have worked out how to program them in Python, and it doesn't look too tricky. In theory, making an arm draw a cross on a page should be manageable, and if it has trouble handling a pen then it could at least pick up and move a cross-shaped object on a table.
The trickier bit would be making the computer aware of what was happening. I think it's possible to get Python to read an image from a webcam, and it should be possible to write a piece of code to look for a circle drawn on the page.
So that should keep me occupied for a while. I bought the arm today. I'll report back when I have some news.
Thursday, 13 September 2012
Android A-go-go
Been a while since I last posted, but the tinkering continues. As we're now offering Computing as a GCSE, we get to teach cool stuff like mobile app development.
The first thing we did today was a simple "virtual pet" app, which is basically the tutorial for creating Android apps using MIT App Inventor. If you fancy doing some beginners' apps, that's not a bad place to start. We also started on a Whack-A-Mole type game, which introduces graphical sprites and timers. It's a simple game, but quite fun to make. I'm not sure how advanced you can get with App Inventor, but some of the demos on the site look very interesting.
We also had the first meeting of what looks destined to be named "Code Club", where kids get together at lunchtime each week and make cool things. First they're trying to decide what to make (web-based app or mobile "thing"), then I'll try to help them make it a reality. I can't wait, even if it means I have to learn Java.
The first thing we did today was a simple "virtual pet" app, which is basically the tutorial for creating Android apps using MIT App Inventor. If you fancy doing some beginners' apps, that's not a bad place to start. We also started on a Whack-A-Mole type game, which introduces graphical sprites and timers. It's a simple game, but quite fun to make. I'm not sure how advanced you can get with App Inventor, but some of the demos on the site look very interesting.
We also had the first meeting of what looks destined to be named "Code Club", where kids get together at lunchtime each week and make cool things. First they're trying to decide what to make (web-based app or mobile "thing"), then I'll try to help them make it a reality. I can't wait, even if it means I have to learn Java.
Thursday, 26 July 2012
How much have the Olympics cost you?
Quick one today. A bit of maths and some tinkering around with Flash movieclips have produced this:
It is designed to run from the start of the Olympic opening ceremony until the end of the games, and works out how much it has cost the individual taxpayer so far. Grumpy? Undoubtedly. Accurate? Probably not.
It is designed to run from the start of the Olympic opening ceremony until the end of the games, and works out how much it has cost the individual taxpayer so far. Grumpy? Undoubtedly. Accurate? Probably not.
Monday, 16 July 2012
Creating Harmony
Last week I did some work on a new project, which came about from a conversation in the staff room. At school, we have a system where pupils stay with the same group of peers for three years. In years 7,8 and 9, the form doesn't change (although the form tutor does).
When they reach year 10, we muddle the forms up and re-assign pupils. Not sure why, we just do. Maybe it's because we change from five forms to six, so we need to redistribute the pupils. However, because we're nice, we don't just assign people to form randomly. We allow them to influence the procedure. Having said that, it might be fun to do it by drawing coloured balls from a big sack. Or maybe we could let a magic hat decide.
Anyway, pupils get to choose up to four people who they would like to be placed with. They also get to choose one person who they would rather NOT be placed with. The challenge is to place 100+ pupils into 6 forms, keeping the most people happy and making sure everyone has at least one preferred classmate.
It takes a teacher about 4 hours to do this job. It's a bit like filling in a sudoku. Just when you have one thing right, you realise that you have created a new problem. Sounds like a job for a computer!
I decided to see if a computer could do it more quickly. As with all computing tasks, the first part is to think about some general rules. I decided on the following:
We would measure how successful an arrangement is by giving it a score. If a person is in the same class as their chosen pupils, the arrangement scores one point per match. If they are in the same class as someone they have chosen to avoid, the arrangement loses two points. Using this scoring system, we can measure any given arrangement and compare it to see if it is better than a different arrangement. We can also grade it against the "perfect" score, which is where every person has everyone they requested. At this stage, I had no idea how easy it would be to find this perfect score, or if it is even possible.
I then started thinking about how to go about testing different arrangements. Computers are fast, so it might be possible to do a "brute force" method and test every possible combination. However, the numbers get very big very quickly. The first person has a choice of 6 forms, so does the next, and the next, leading to a possible 6^100 combinations. This is not feasible to compute in a reasonable time.
So a completely dumb loop through every combination would take too long. I needed a smarter method of testing candidate arrangements. I decided on the following algorithm:
- Take a random pupil.
- Look at each form and test to see how "harmonious" it would be with the new pupil (scored as previously described). If there's an obvious best choice, put them in there so long as it is not full (each form has a maximum number of pupils).
- If there is more than one best choice, or the best choice is full, choose again based on class size. Put them in the smallest form.
- Take another random pupil and repeat until all the pupils have been assigned.
- Once all pupils have a form, assess the "harmony score" of the whole year group.
- If it's better than any arrangement we have seen so far, keep a record of the form arrangements.
- Wipe all the forms and repeat until we have either found a perfect arrangement or we give up
After I programmed it, I set it loose on the real data from last year's options. I entered all the names and the options for the actual Year 9 group and started off running the program for 1,000 attempts. On each attempt, it picked pupils at random, so there was an equally good chance of hitting a workable combination at any time. It didn't find a perfect arrangement, though. It couldn't even find an arrangement where everyone had at least one preferred classmate. I tried it again for 10,000 loops with no luck. I even set it going for 100,000 loops, and it couldn't find a perfect outcome. It was close, though. In just a few minutes, the program had managed to find a solution where all but three pupils were happy, and many of them were very happy indeed because they had all their preferred classmates. I worked out that a human could look at the solution and do some manual shuffling so that the last 3 people were happy. At the least, it would shave a significant amount of time off the 4 hours the job had previously taken.
Then I ran the program again, and it found a great solution almost straight away. And the next time, it did it again! Because it's picking randomly, it could find a solution quickly, or it could take a while. I'm sure there's a more efficient way of doing the job, but for the moment it looks like the program can definitely make a contribution here. It just needs tidying up and a decent interface so that pupils can enter their preference directly. I've even thought of a name: Harmoniza.
Sunday, 24 June 2012
WGHS Rooms App Early stage
Some progress on my little app for booking rooms at school. It has a login screen and currently returns a list of upcoming room bookings...
...which is just a specially formatted web page.
Yeah, it's not going to be out-selling Angry Birds, but the important thing is to learn how it's done!
...which is just a specially formatted web page.
Oh, and it has an icon.
Yeah, it's not going to be out-selling Angry Birds, but the important thing is to learn how it's done!
Subscribe to:
Posts (Atom)

