nuo

Nuo writes:

How time flies. It’s been almost 4 weeks for me to be here as an intern. Being an intern at Microsoft is just wonderful. We are not only able to know the technology, the business, etc, but also had a lot of opportunities to meet different people and go to different events, which is fantastic. And don’t forget the fact that we work on real things which customers will see. In my feeling, the internship is just a short-term full time employment with a lot of extra activities. :-D

To talk about a few of the events, in my second week here I was lucky enough to attend a BBQ in Bill Gates’ house with some other interns and executives. For many people, which including me, going to his house is a super exciting thing. However, that‘s just not all. In his house we had chances to talk to him and ask questions in a relax setting. It was a great opportunity to learn about his vision of technology development in the next several years and his decision to fight several global diseases that his foundation can put effort on. During the dinner, I also talked to many interns and executives from different product groups, so I learned a lot about their businesses.

We also have weekly intern socials and weekend activities, some are organized by the intern program and some are organized by ourselves. During the weekend we usually meet at one of the buildings on campus, then travel to some places of interest together by shuttle or carpool for a day trip. For example, places we went to including the beach in Oregon, the Olympic National Park, and the Mountain Rainier, etc. I only attended a few, compared to those available; however, I’m already “busy” enough.

As interns we have a lot of benefits. We have bus pass, free gym membership, free soda and coffee, etc. We are also given a discount card which is accepted by many vendors in the United States. For example, in many restaurants we can get the second entry free; in some car dealer we have life time free oil change, etc. And the fact I like the most is we are working on real things. I have the feeling that as an intern I’m not really just coming for learning things, but doing projects people will see. It’s really exciting. In addition, we have access to Microsoft library and the internal training resources. I myself already attended many in person and online classes and never learned so much about content publishing, software development, and program management.

Now is the time to talk more about my project – Windows Mobile Starter Kit: Tic Tac Toe . In my last post I mentioned the implementation of enabling ink recognition in 9 child windows, and this time I will talk something about how I implemented a user vs user game.

Since every time the user writes something in one of the 9 ink windows, recognition will begin to see what the user wrote. Then the easiest way in my mind to implement the user vs user game logic is to check whether the user wins if X or O is recognized. And the way to check it is to see whether there are three same letters in a line. So I created a Boolean array of flags for identifying whether a window has been filled; and a string (actually char*) array to store what letter is in the window. I identify the 9 ink window, 9 Boolean flag and 9 strings in the same way: 0 to 8. So the arrangement is like the following table:      

0

1

2

3

4

5

6

7

8

 

If one window is written X or O, then the Boolean flag of that window becomes TRUE and add the uppercase of that letter to the string result set. Then perform a check of whether any line containing that window has three TRUE Boolean flags and whether the window of the three TRUE flags has all the same letter in the result set.

For example, if the user writes “X” in “0,” Boolean flag for “0” turns to TRUE and “X” is added to the 0 item of the result set (resultset[0]), then DoRecognize() function will check whether the value of the Boolean flag in 1, 2, or 3, 6, or 4, 8 are TRUE. If not, then no one wins;  if any set of them are TRUE, then check whether the three element has same letter in the result set, if so, then that user wins.(e.g. if(strcmp(resultset[0], resultset[1]) == 0 && strcmp(resultset[1], resultset[2])==0){someome wins!}).

So I implemented several functions to do these jobs. I had a DoU2UWinnerCheck() function which is called in DoRecognize() function to perform winner check and pop up message box if someone wins. I had another Boolean function IsWinU2U() is called within DoU2UWinnerCheck() for doing the checking details of whether someone wins, if so, return TRUE and otherwise return FALSE. If it returns TRUE, then DoU2UWinnerCheck() pops up the message box.

However, DoU2UWinnerCheck() does one more thing, which is to check the “Tie” case. If IsWinU2U() returns FALSE to DoU2UWinnerCheck(), then DoU2UWinnerCheck() will check whether all nine Boolean flag has been marked as TRUE (occupied), if so, then pops up a message box stating “Tie,” otherwise just returns back to DoRecognize().

After testing, this implementation works! Well I originally thought of a more complex way of doing it by using matrix and maybe two dimensional arrays. That way will save some code however will have the overhead that more human errors may be easily involved. I realized this is not an assignment for my matrix or algorithms class so I implemented the way which is easier to understand and efficient enough.

Next time I will talk about the arrangement of UI elements and the implementation of the adaptation for different screen sizes.

I’d like to hear any comment or suggestion about the project.

Nuo