Tuesday, 31 January 2012

Waterloo Game Analysis

Microsoft created the Facebook Game Waterloo in order to do some research on game theories.

Tonight, just for fun, I wanted to create a piece of software that enumerate all the possible combinations and find the move with the highest probability of win (one Nash Equilibrium).

I created it using a simple C# console application.

First of all, I created a function that returns a list of all possible moves for each player (the funniest part):

After that, for each pair of moves, I calculated the number of wins and finally get the better move.


The implementation of the Win extension method:

and the main body:

This is the output of the basic example:



Using total = 15 and n = 5 the result is:


The Waterloo game use total = 100 and n = 5. With these numbers the code is too slow to terminate but you can easily guess that the result will be (20, 20, 20, 20, 20).

If you are curious about the total number of possible moves in Waterloo I can tell you this with the following code. The code analyse a specific Waterloo move telling you what is the probability of win in addition to the total number of moves.

 





The output:

So, the total number of moves is 4598126 !!!

The move (20, 20, 20, 20, 20) is the "best move" in terms of probability. However, if you play against a human being it is probably easier to come up with a solution like (33, 33, 34, 0, 0) or (34, 34, 11, 11, 10). In both the cases, if you use the "best move" you lost.

Let's see the result using (33, 33, 34, 0, 0):







Let's see the result using (34, 34, 11, 11, 10):


Arrived at this point I feel a little bit lost. What is the best solution?

Probably there are more Nash Equilibrium's and the solution should be a probabilistic strategy instead of a simple move.

Let's see what will be the result of the research.

If you want to learn more about Game Theory, you can watch this introduction course taken from the Artificial Intelligence class:
https://www.ai-class.com/course/video/videolecture/164

You can find the full source code in my personal repository: Waterloo Game

UPDATE: Code from IanS

IanS proposed a recurvise implementation of the "combinations" algorithm. It it probably slower then mine (it is a recursive algorithm) but has the advantage of readability. This solution has the interesting property of not using any explicit assignments or increment operations.



Thank you Ian for your feedback.


Sunday, 29 January 2012

Unlimited Internet and my new Android device

Yesterday, I finally solved an important problem.

As many of you know, I am living in UK while my girlfriend live partially here and partially in Italy. We tend to stay quite in touch with each other but this costs me a lot of money. Unfortunately there are no telephone companies with offers on text between countries.

The solution? Unlimited Mobile Internet.

We started from the following situation:
  • I have a vodafone italian card without Internet access
  • I have a Windows Phone 7 device (LG Optimus 7)
  • She has a vodafone italian card without Internet access
  • She hasn't a smart phone
We decided to move to 3 and get two UK Sim cards with unlimited Internet and the offer with two android devices (two years plan). I could simply buy the Sim card and using my Windows Phone but the price was almost similar. I choose an Android device because it was silly to me to have two Windows Phones.

The situation is now:
  • We both have a smart phone with Android
    (Sony Ericsson XPERIA)
  • I have a Windows Phone 7 device with my Italian Sim card
  • We both have Unlimited Internet in UK
  • We both have lots of text and calls for free every month
  • I reduced my telephone costs of more than 50%
Yesterday, I played all the day with my new phone :)

Having Unlimited Internet is awesome. You feels like the entire world is in your hand.

Fantastic !!!




My New Official Blog

Hello,

It is a while that I am considering ways to centralise my presence on the web and I finally decided what to do.

Until now I had three blogs and one personal web site:
In the past, I made the decision to separate technical blogs from personal blogs and trying to differentiate between Italian and English but actually I realised that has been a very very bad decision. When I wanted to create a post I had to decide the language to use and try to identify the type of content in order to choose where to write. However sometimes it is difficult to make this choice because some content are both technical and personal. In addition creating a pure impersonal technical blog is sad. For this reason I often mixed the things in strange ways loosing completely my original intention to differentiate. The advent of Facebook changed the rules significantly because I started to publish my personal stuffs there so I almost stop blogging.

At the same time I didn't want only a simple blog but I wanted a single personal homepage with a blog inside it. I basically wanted a single entry point to my digital life. Implementing a portal like this manually requires a lot of work and I couldn't really afford it in a reasonable time. Fortunately, I realised that BlogSpot could be easily solve all my problems.

Why BlogSpot:
  • Extremely easy to setup and use
  • Easy to customise with lots of gatdets available
  • Possibility to create custom pages in addition to the blog (the blog itself is just a page)
  • Possibility to choose a custom domain name (andrea-angella)
  • Possibility to add a new post using the browser (no need of external software like Live Writer)
  • Possibility to check the spelling
  • Support for mobile devices
  • Well integrated with Google services (Of course, this is Google)
  • Free
Unfortunately I didn't find a way to export my old posts in a format acceptable for import. For this reason, I imported manually only the most important old posts.

An another important decision is the language. For obvious reasons, I am going to write most of my posts in English. After all, I am living in UK and this seems the right decision. English is the way to reach a vast amount of people but I am very sorry for some of my Italian friends that could have problems reading my posts. For you, I suggest using automatic translation services offered by Google that are easily accessible at the right of the page. An another quick option is to install the Google Toolbar to get translations with a single click by adding one of the buttons below to your browser's toolbar.

I probably won't remove the others blogs for a while but I am not going to update them anymore. For this reason, please, consider this as my only blog.

This is my only blog.

My intentions with this blog are the following:
  • Create a single entry point to my digital life with links to my presence in the web
  • Share with the world my opinions and some technical stuffs
  • Receive constructive feedbacks
  • Keep track of my life experiences and my learning for personal reference
  • Improve my writing skills in English
Thank you






Wednesday, 31 August 2011

Windows Phone Camp in London

 Next 17 September will be a full immersion day of Windows Phone 7 Mango Sorriso





Tuesday, 23 August 2011

Exam passed: “MCTS - Windows Applications Development with Microsoft .NET Framework 4”

I am definitely not a guru of WPF but recently in my company I had to play with it a little bit and it was the right opportunity to prepare the certification.

The 15th of August 2011 I passed the certification exam:
“MCTS - Windows Applications Development with Microsoft .NET Framework 4”.

This is how looks my certification logo at the moment:


For many people certifications are not important or required. However, I believe that setting goals and achieve them is very exciting. If you studied at the university like me, you know what means passing an exam. Well, that kind of emotion allow you to continue towards higher goals.
This time I want to achieve the professial level MCPD.

Before this, I have to pass other two MCTS level certifications:
  • MCTS: .NET Framework 4, Data Access
  • MCTS: .NET Framework 4, Service Communication Applications
Let's start :)

Before to finish, I want to underline some important aspects when you want to prepare a Microsoft certification:
  1. Don't use only the official preparation book because it contains a subset of the required arguments.
  2. Read carefully the section "Skills Measured" and check that you covered all the subjects
    1. In this case, for example, it was easy to unnote that the exam included the Task Parallel Library and Parallel LINQ
  3. Take practise tests on MeasureUp is a big help and you shouldn't understimate this
One thing that I liked is that, comparing to the last time I did an exam (two years ago), the complexity was higher. Questions were less trivial that asking what is the name of a certain method (useless questions). Questions were about concepts in order to test your deep knowledge of certain subjects. It seems clear the work that Microsoft is doing to make certifications more valuable.

Friday, 12 August 2011

Unit Test Lab il 24 Settembre 2011 – Tenetevi pronti

Ciao a tutti,
appena prima delle meritate vacanze estive DotNetToscana vuole rivelare alcuni dettagli del prossivo evento laboratorio.

La data à già stata fissata a Sabato 24 Settembre 2011 mentre il luogo deve ancora essere confermato.

Il laboratorio sarà guidato da Matteo Baglini mentre gli altri membri dello staff forniranno supporto tecnico ai partecipanti.


Segue una breve descrizione dell’evento:

Uno degli aspetti più controversi dello sviluppo software è sicuramente il test.
Pratica da molti reputata importante per ottenere un software di qualità ma allo stesso tempo snobbata. La realtà è che gli sviluppatori preferiscono progettare e realizzare il software piuttosto che testarlo lasciando quest'ultimo compito al team di tester. Esistono molteplici tipologie di test, lo Unit Test è uno di questi e rappresenta uno strumento importante per i tester, ma soprattutto per gli sviluppatori.
Durante questo laboratorio potrai provare con mano la pratica dello Unit Test e trovare risposta alle tipiche domande: perchè, come e quando effettuare Unit Test. Imparerai i principi che guidano lo Unit Test passando dalla teoria alla pratica, applicando questa tecnica in svariati contesti.
Maggiori dettagli seguiranno alla fine del mese,

Buone vacanze a tutti,

Vi aspettiamo,

Andrea

Saturday, 23 July 2011

101 Ways to Motivate Yourselft and Others – My favourites

Recentely Sources of Insight published a really interesting post: 101 Ways to Motivate Yourselft and Others.

As a reminder, I would like to write the points I considere more important for me and where I want to work:
  • Act on your inspiration
    • “Use your best energy for your best results”
    • "Your passion can expire, if you wait too long or miss the window of opportunity”
    • “A common way to kill idea or momentum is to spread them out over time, or keep pushing them out”
  • Be a coach, not a critic
    • “Use your inner coach for constructive feedback, and give your inner-critic a break”
  • Be on fire
    • “You know when you’re on fire. You kno what you’re like when you’re in the zone and you’re fully engaged and you’re at your best. Sometimes, the easiest way to get back to this mode is to simply remember what if feels like”
  • Be YOUR best
    • “Compete with yourselft and make it a game”
  • Build your band of merry men
    • “Surround yourself with the people that inspire and deligh you, wherever you go”
  • Change the frame, to change your game
    • “Problems aren’t problems when you reframe them as challenges. Challenges are opportunities for growth, excellence and your personal best”
  • Chart your progress
    • “If you want to motivate, find a way to keep the score. Progress is the top motivator of performance. Even incremental progress boosts motivation”
  • Choose significant tasks that are meaningful for you
    • “If you like excellence, then challenge yourself to shine”.
  • Create a wall of inspiration
    • “Put those pictures up that show you the greates things in life and what’s possible. Get those hopes and dreams up on the wall that remind you what’s worth fighting for.”
    • “Put those wards on the wall and quotable quotes that fire you up and make you feel alive”
  • Decide
    • “Nothing builds momentum like decisive action. Just Decide.Decisive action is motivation, it build momentum and it crowds out excuses”
  • Do worst things first
    • “Don’t let things loom over you. Once they’re out of the waym the rest is a glide-path”
  • Don’t let feat stop you
    • “A great way to conquer fear is to put the fears on the table and find a way to take away the thread or prepare for the worst case scenario”
    • “The only thing we have to fear is fear itself”, Roosevelt
  • Don’t be perfectionist
    • “Perfection is a fallacy and it’s over-rated. A better focus is to be effective. Make it work, then make it right. Think of perfection as a process of improvement.”
    • “Focus on good enough for now. and satisfice”.
    • “Taking action is a key way to stay out of analysis paralysis, and keep your motivation strong. Don’t worry about the perfect place to start, just start”
  • Don’t look for execuse
  • Don’t take yourselft too seriously
    • “Build your sense of humor”
  • Eat, sleep and exercise on a cadence
    • “Your cadence will serve you emotionally, mentally and physically”
  • Find your “one thing”
    • “One thing matters to you most. Do more of that. That’s the thing to focus on”
  • Finish faster
    • “The faster you finish, the more you will finish. The more you finish, the easier it gets”
  • Focus on what you want
    • “Get a clear and compelling picture of what you do want and focus on that”
  • Play your favorite music
    • “Play the songs that make your spirit soar”
  • Reming yourself how short life is
    • “One way to give your fall is to remember that nothing lasts forever”
  • Set a deadline
    • “Knowing when something is due can help you funnel and focus your action and attention”
  • Set extreme goals
    • “Sometimes goals have to be extreme to feel worth it. Dream big. Set crazy limits or hurdles”
  • Want it with a passion
    • “Nothing beats the pursuit of a worhy and compelling objective”
  • Keep in mind that knowing and doing are two different things
    • “You hold the keys to unleashing what you’re capable of”

Saturday, 25 June 2011

Discussione: metodi efficaci di apprendimento.

Ciao a tutti ragazzi,
sto leggendo il libro “Pragmatic Thinking and Learning” e mi sto soffermando su alcuni punti interessanti legati all’apprendimento.

In particolare io mi riferisco al nostro settore quindi all’apprendimento in ambito IT (tecnologia, design, architettura, metodologie, …).

Come sappiamo esistono differenti modi di apprendere:
  • Leggere libri
  • Realizzare un progetto personale
  • Apprendimento tramite esperienza in azienda
  • Apprendimento tramite corsi offerti dall’azienda
  • Partecipazione a sessioni tecniche e a community
  • Webcast
  • Podcast
  • Lettura di articoli / blog sul web
  • Mentoring
  • Gruppi di studio
Sicuramente tutti dobbiamo lavorare e quindi l’apprendimento tramite esperienza in azienda e’ abbastanza scontato ma a mio parere non e’ sufficiente per costruirsi una brillante carriera. Spesso in azienda sei costretto a compiere decisioni con una conoscenza incompleta mentre a me spesso piace un approccio graduale all’apprendimento che al lavoro non e’ quasi mai praticabile. Inoltre al lavoro non utilizzerai mai tutte le tecnologie ed e’ quindi necessario un lavoro esterno di compensazione e di espansione delle proprie conoscenze. Nonostante la partecipazione a community, il guardare webcast la mia fonte preferita di apprendimento sono i libri. Il motivo principale e’ che dietro al libro c’e’ un lavoro immane di raccolta materiale e riorganizzazione che e’ estremamente utile per il lettore che si ritrova una esposizione dei contenuti in maniera lineare e chiara. Tuttavia e’ noto che leggere richiede tempo e non e’ la forma preferita di apprendimento per l’essere umano che spesso impara piu’ velocemente imitando e osservando invece che leggendo.

Ci sono tantissimi professionisti che stimo e rispetto (e molti sono qui su ugi) con un bagaglio di competenza tecnica immenso che spazia campi di applicazioni diversi e sorge spontanea la domanda:

Qual e’ il vostro modo efficace di apprendere?

Come e’ evoluto nel corso degli anni?


Una classica risposta e’ con la pratica! Si e’ vero, capisco che la pratica e’ la chiave ma qui entra in gioco il fattore tempo.

Quanto tempo extra-lavoro dedichi all’apprendimento?


Io personalmente ne dedico molto in quanto sono estremamente appassionato ma misuro che i progressi non sono rapidi come vorrei.

Il mio manager dice che e’ solo una questione di esperienza ma non condivido la sua affermazione. Voi?

Condividete la vostra esperienza perfavore, penso che possa nascere una discussione interessante.


Per concludere vorrei riportare una frase significativa del libro:

“There's always going to be a new technology or a new version of an existing technology to be learned. The technology itselft isn't as important; it's the constant learning that counts."