C# Yield Return Fun
/public static IEnumerable YieldFun()
{
yield return 1;
yield return 2;
yield return 3;
}
static void Main(string[] args)
{
foreach (int i in YieldFun())
{
Console.WriteLine(i);
}
}
If you can tell me what the code above does, you understand how yield return works. If you can’t, read on……
In a C# program you can mark things as implementing the IEnumerable interface (to use this you need to have a using System.Collections; at the top of your program). This means the thing can be enumerated, i.e. it means that I can get a succession of objects from it.
The best way to work through something that can be enumerated is by using the foreach construction, as shown above. You’ve probably seen foreach when you’ve worked through items in a collection such as a List or an array. In the above code we are using foreach to work through the enumerable results that the YieldFun method returns.
The code inside YieldFun looks a bit scary. The yield return keyword combination is followed by the thing that you want to send back for this iteration. In this case I’m just returning a different number each time. What happens when the yield return is reached is that the method stops at that point, returns the result and then, when the foreach asks for the next value, the method wakes up and continues at the next statement. The result of the program is simply the sequence:
1
2
3
If you want to programmatically supply a sequence of items to a consumer then this is a great way to do it.
The Rob Miles Roadshow
/Next week I’m doing a Mix session all about game development in XNA, stay tuned for some brand new examples and sample code, but unfortunately no new jokes. I’ve just found out that I’m also doing Ask the Experts on Tuesday evening starting at 6:00 pm (and for once I’m not going to be doing the asking). They are using a “speed dating” arrangement where we meet up with a bunch of folks for 20 minute slots where we get over the gist of what we are at Mix for. I’ll be doing Windows Phone games (of course) and I’d love to meet you if you come along. Strange this, nothing for years and then two sessions of speed dating in a matter of a weeks.
If you are lucky enough to have a Windows Phone you can download the official Mix application which is great. And also mentions me. Search the marketplace for “Mix 11”.
The “Rob Miles Roadshow”™ then rumbles on to TechDays later this month. They also have a really good Windows Phone application too, although this one works best if you can speak Dutch. Search the marketplace for “Techdays”.
I’m doing a session on Windows Phone games, another on the .NET Micro Framework and a third (deep breath) where I’m going to be talking about Windows Phone development in rhyme, just for Geek Night. And I’m also making an appearance at one of the keynotes too. Now, if that’s not a reason to buy a new pair of jeans, I don’t know what is… Find out more here.
Prizes and Rewards with Windows Phone
/There has never been a better time to be a Windows Phone developer. If you are a UK student you can take part in a Student Competition where you can win prizes just by submitting applications to the Marketplace. Since you can also sell these applications, and it costs you nothing to join the Marketplace if you register via DreamSpark this seems like a pretty good deal. Find out more here.
If you are old like me and therefore no longer a student you can instead sign up for the Think.Dev rewards programme and get prizes and rewards for submitting apps. This is open to all Windows Phone developers in the UK and you get stuff for just turning up and submitting apps. I might even win a prize for Cheese Lander (although this is probably unlikely). Sign up here.
Headphone wires aren’t what they use to be
/
All I have to do now is solder them onto a plug. Yeah, right.
My lovely (and so expensive I never told number one wife I bought them) Ultimate Ears headphones have broken. The wire that goes into the plug has failed on one of the connections. Being a chap who’s not afraid of hardware (perhaps because I don’t know that much about it) I was happy to get a new plug and solder it on. That is, until I saw what passes for wire these days.
In the Olden Days ™ headphones were wired with the next thing down from mains cable, which could be dismantled and worked on with industrial scale tools. My old Sony phones were much tougher too. They even survived a trip around the robot vacuum, which took a fancy to them one day.
Nowadays, with fancy “litz” cables and stuff it looks like it is pretty much impossible to mend the darned things. And they aren’t even heavy enough to serve as a decent paperweight.
Getting your Xbox Live Avatar Image
/
This is me…
It turns out to be very easy to get hold of your Xbox Live Avatar in image form. You can just put your gamertag into the following URL in place of TAG HERE:
http://avatar.xboxlive.com/avatar/TAG HERE/avatar-body.png
This returns an image that you can then use anywhere you want a picture of your virtual self. Very nifty.
Rob at Mix 11 in Las Vegas
/For those of you lucky enough to be going to Mix this year, I’ll be joining you as well. I’m giving a session on Tuesday 12th of April at 11:30 am in Breakers D. The subject is “XNA Game Studio for Fun, Profit, Danger, Excitement and Windows Phone 7 Games”. There will be all new content, but all old jokes.
I’m also doing a booth session in the Windows Phone Booth (good name that) at 2:00 pm on the same day. Feel free to drop by and say hi. I’ll even sign copies of my book that you’ve bought….
Mega Open Day
/
This is some of the audience for our mega Open Day. Great turn out.
It is scary how fast time goes by. We are running towards the end of the Open Days for this academic year. We are going out with a bang though, the turnout for today’s event was huge. This placed a certain amount of strain on the rooms that we have. We didn’t actually make the design lab bulge, but we came close. Thanks to everyone who came along, hope you had an interesting and enjoyable time with us.
As usual we gave away a copy of my book as a price, here is Warren handing it over. Note that we have now got some copies of the latest version (in all the shops now).
Find out if you are using the Windows Phone Emulator
/It is often useful in a Windows Phone program for the code to know whether or not it is running on a real device. It is actually easy to do this:
- Add Microsoft.Phone to the references to your project if it is not already there.
- Put the following line at the top of your program.
using Microsoft.Devices; - You can now write code like this:
if (Microsoft.Devices.Environment.DeviceType ==
DeviceType.Device)
{
// we are running on the real phone
}
You can use DeviceType.Emulator in the test to see if you are running on the emulator.
Some Windows Phones Contain NASA Chips
/Sadly, my phone just contains ordinary chips…. such is life.
It turns out that your Windows Phone 7 device might be worth a lot more than you think, if it contains custom, radiation hardened memory chips, mistakenly installed when it was built. Apparently, because the part numbers of the memory chips only differ by an H (for hardened) production plants put the highly valuable devices into a number of Windows Phone devices when they were made.
Ivan Felfrit, NASA spokesman, is saying that these chips were originally destined for the next generation of Mars Rovers, Spirit II and Opportunity IV. “We need several sets urgently” he said earlier today, “We have to test the programs on genuine hardware and we also need the devices for endurance testing”. NASA are happy to give you a replacement phone and 10,000 dollars if you have a device with these components inside. They have advanced surface mount labs where they can remove them and install them in Mars Rover prototypes.
To find out if your phone has the chips in it, just to to Settings->About and touch “More Information”. You should see the screen above. If the Chip SOC version is set to 0:36.2.0 you have the NASA chips. Mine above only has 0.36.2.6, which is the standard devices. Either chip works fine, it is just that the NASA ones are worth more, and might be going to Mars. If you think you might have the NASA chips, send an email to i.felfrit@wp7formars.com and he will get right back to you.
30 Minutes in Paris
/I went to Paris today. For half an hour. That’s the time it takes a person to sprint from terminal 2C to terminal 2F, jump the security queue and collapse exhausted on seat 10A of the flight out. The lady at the Air Bulgaria desk in Sofia expressed surprise that I was flying from Sofia to Amsterdam today, what with there being no flights in that direction. Fortunately the airline computers were equal to this, and had me going to Paris first, and then to Amsterdam, and then a six hour wait and then a flight back to Hull.
Lovely.
Fortunately I managed to sprint across the airport and made it just in time. The rest of the journey passed without incident, although Schipol airport is not actually the most inspiring place to spend the best part of a working day.
The whole trip was worth it though. I’ve met some splendid folks and had a great time. I know it is very dangerous to extrapolate a whole race and culture just from the few people from there you happen to meet (I dread to think what would happen if folks started thinking all English people were like me) but I really liked the Bulgarians I met up with (and I saw quite a few when we were “Speed dating” on Tuesday). They don’t suffer fools gladly. If you ask a confirming question (which I am wont to do), for example “So that means the Airport Shuttle will be leaving at 5:00 am?” they will look at you as if you are an idiot, bearing in mind they have just told you this. Actually, thinking about it, it was a rather idiotic question though…
Bulgarians also seem to have an earnest seriousness when you first meet them, but this quickly turns to riotous humour – which is great.
We went out for a meal last night. Great food and the beer was really nice but we had to have several glasses just to make sure..
Sofia airport coffee at 5:45 am..
Windows Phone at MS Days
/Did my second session of the day on Windows Phone. This is some of the audience before the start. Thanks for being another great audience folks. Everything worked, in some cases eventually. My “party piece du-jour” was to start the program on the device rather than the emulator. I did it pretty much every time, in the end the people watching were spotting it before I did.
I got a question about Windows Phone Marketplace during the talk and I said I’d follow up on these pages. As I understand it this is as much a legal as a technical issue, in terms of how the law works in Bulgaria. At the moment you have to go through another publisher I’m afraid, which means people like http://appamundi.com/Publishing/ or http://www.yallaapps.com/.
You can find all the content from the lecture, including slides and demos, here.
After I’d finished I had a wander round and took some pictures of the conference.
Who knows what goes on behind these doors….
Nice Banner
Windows Phone, Bulgarian style
The conference is being held in a huge cinema multiplex. If you hurry you might make one of the 10:00 showings..
Nice Lights
Fun at Microsoft Days
/Got my conference badge this morning, along with a very fancy pin which marks me out as a speaker at the conference. I got in and got set up and then went and watched one of the keynote sessions. The first part was in Bulgarian, which was pretty much lost on me I’m afraid, but the main talk was by Mingfei Yan, who talked about the cloud and how it is going to change everything. I reckon all of our students should see this, lots of food for thought about the way that computing is going.
At one point she showed some augmented reality, where a 3D car model was streamed down onto a marker on a piece of paper. Great fun.
Then it was time for my Micro Framework session.
Everything worked and I had a great audience. This is some of them as the room filled up. Some great questions and a round of applause at the end. Although it was probably for the robot.
I’ve put all the resources for the talk here.
On now to experts lounge and then the Windows Phone talk.
Hello Bulgaria
/Flew out to Sofia today to give some sessions at Microsoft Days 2011. The journey out was complicated slightly by a two hour delay on the flight from Amsterdam to Sofia. They didn’t actually announce “The flight is being held up while we put the seat in front of Rob into the ‘permanently reclined’ position” but I think that is probably what happened.
Anyhoo, I made it in the nick of time for our trip to a local university Damien Caro and myself met up with a bunch of students and, once we managed to make our laptops talk to the projector, we had a great time. I gave a demonstration of my silly robot and a Windows Phone game involving cheese. Damien talked about the Cloud which is going to change our lives.
I took a picture just as everyone was leaving. Thanks for being a great audience folks.
Starting the speed dating
Then. straight after our lecture, it was time to head off to a trendy city centre bar for some ‘speed dating’ with journalists. This was one of the most intense things I’ve ever done. We had five minutes with each person and we were shouting introductions, questions and answers over each other. Great fun, although I ended up a little hoarse by the end.
One journalist had this amazing handbag.
After that it was time to head back to the hotel and make sure that my little robot knows his lines for tomorrow.
Three Thing Game Judging Videos
/If you want to see what the teams came up with at the end of the game event, and how well students can function after sleep deprivation and lots of caffeine and sugar, then they are all now available on youtube. Just search for threethinggame These videos are in High Definition, as I’m sure you will spot.
We had Paul Ross from Criterion Games here today (they are the studio behind titles such as Burnout) to give a talk on game development and chat with our students. This was the cue for lots of scrambling for Windows Phone devices so that some of our team members could show him the things they had made during the competition. By all accounts he was very impressed, which is nice.
Anyone who missed out on taking part in the competition this time round needn’t worry. Three Thing Game will be back next semester.
Three Thing Game Judging at Platform Expo
/
Yours truly with “To Be Confirmed”, whose take on “Warrior Koalas on Mars” got them a Windows Phone each. Good work guys. Now put it in the Windows Phone Marketplace.
We put 60 or so bleary eyed students on a double decker bus and drove them down to Platform Expo for the judging.
They must be judges, they’ve got clipboards…
All the group watched the judging videos (which will be online soon) and asked a bunch of questions about the entries. At noon we announced the winners. The students then had an hour or so to explore the expo (or collapse somewhere) and then the trusty bus brought them back to campus.
Every team stayed the course this time, and we had playable content from all of them. Some of the teams did amazing things with some truly tricky starting points and they stuck to their subjects really well. I’m terrifically impressed with all the students, who served as ambassadors for the university at every level. We even had a bunch of volunteers who had given up a chunk of their Sunday to come and demonstrate the 3DS to people at the expo.
Jon and I did talks about 3D displays and Kinect that were well received and well attended (although I’m not sure how coherent we were only having had 3 hours sleep in the last 36).
Great fun, if exhausting. I’ve put a load of pictures up on Flickr (search for the tag threethinggame) and I’ll be uploading the judging videos on Monday.
Three Thing Game Team Videos
/I’ve been round all the teams and done brief videos of how they are getting on:
I’ve also put captions on the pictures on Flickr..
http://www.flickr.com/search/?q=threethinggame
I’ll do this all again later tonight, and see what progress we’ve made.
Three Thing Game Gets Going
/These are the teams at the start of the competition. I’ll do another of everyone at the end…..
Awesome prizes, I think this explains the good turnout.
We’ve launched the game development competition today. We have over 60 students involved. They are all busily in the development phase of their games at the moment, just a few hours left now…..
If you want to see what they are up to we have a variety of webcam feeds for you to choose from:
http://www.ustream.tv/channel/twenty-four-hour-game-dev
http://www.ustream.tv/channel/24-hour-game-dev
http://www.ustream.tv/channel/fresh-pot
I’m putting regular picture updates on Flickr and there will be videos later when I’ve been round and chatted to all the teams. And everyone is tweeting as well. The tag threethinggame will get you where you want to be.
Pex for Windows Phone 7
/I write programs for fun. Seriously. I’ve got games at home still in the box because I’d rather fiddle with some C# on Windows Phone than try to kill demons/drive cars/fly spaceships etc etc.
Pex is a great way to play games while you write programs. I’ve played with the web version before and now I can do that on my phone too. You can download Pex4fun and play along too. If you have any interest in brushing up your C# smarts in a fun (and portable) way then get this on your phone. It’s free too.























