Web Design. Development. Optimization. RSS 2.0
 Wednesday, May 26, 2004

Mark Cuban has posted the next article in his interesting series on the secrets of his success. Mark Cuban is one of those guys I would really love to meet one day. Not because he's rich, but because he has an interesting perspective on IT and IT things built through experience.

 

Wednesday, May 26, 2004 1:18:14 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Technology
Del.icio.us Digg Technorati Blinklist Furl reddit
 Tuesday, May 25, 2004

Microsoft announced a cool new product called Visual Studio 2005 Team System. It puts project management, architecture, and unit testing tools right into the Visual Studio IDE.

I can't wait to get my hands on it.

 

Tuesday, May 25, 2004 1:41:48 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Technology
Del.icio.us Digg Technorati Blinklist Furl reddit
 Saturday, May 22, 2004

OK, I promised yesterday to release the .NET client application I wrote that interfaces with my Rock-Paper-Scissors (RPS) web service, so here it is:

RPS Client v1.0 - Source Code and Binary

It's a very simple app. I wrote it in 45 minutes or so, so don't judge me to harshly on it. Here's a screen shot.

As you can see, after 50 hands, my web service kicked my human ass, 20-12. I haven't yet added any of the advanced RPS code in there either.

 

Saturday, May 22, 2004 1:52:50 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Demo Code
Del.icio.us Digg Technorati Blinklist Furl reddit
 Thursday, May 20, 2004

I must say, after spending all of 45 minutes writing a complete Rock-Paper-Scissors game client to the web service I wrote last night...

I LOVE .NET

Consuming a web service in .NET is crazy simple.

Step 1. Add a Web Reference to the web service URL.

Step 2. Instantiate an object using that reference.

    rpsservice = new RPSClient.com.mydemos.www.ScottRPS();

Step 3. Use the object, just as you would any other object in .NET.

    rpsservice.ShakeHands(iGameId);

Wow. I love it when products just work. No fuss, no muss.

 

Thursday, May 20, 2004 3:23:02 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Technology
Del.icio.us Digg Technorati Blinklist Furl reddit

With the help of Google, I was able to discover that there has been quite a bit of research into Rock Paper Scissors (also called RoShamBo) theory. This research can be summed up as follows:

a) It's very hard to improve on the “Choose At Random” method. Out of 125 programs submitted to a recent competition, half of them performed worse than Choose At Random would have.

b) There are a couple of decent algorithms out there, that examine the history of an opponents moves in an attempt to predict the next move. These do slightly better than choosing at random.

c) There are a couple of decent algorithms out there that combine 5 or 6 other algorithms, and simply choose the one that has been performing the best. These do even better.

To sum up the above summary, there is no way I can improve on any of these programs. Some of these programs have been written by Doctorate students, and some by AI experts.

I am left with two choices with respect to my RPS program.

Choice A) Pick the best performing alogrithm with public source code, and implement that in .NET.

Choice B) Just continue choosing RPS at random, which relies pure chance (50/50) to win. I may not win, but I could still finish in the top half.

I haven't decided which way to go. I'm going to see how easy it would be to port the C programs to C#. If it's too much work, I may forget about it.

I still need to make a few improvements to my program. I'd like to develop a better way of recording results. Currently, I write everything out to a log file. Maybe I need a separate log file analyzer for RPS. Also, maybe I could write a Web Serivce Consumer, so I can play RPS against the program. That would be cool.

Lastly, there is a Simpsons episode where Bart thinks: “Good ol' Rock. Nothing beats rock.” I'm tempted to go that route as well. (Choice C?)

 

Thursday, May 20, 2004 1:54:01 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET
Del.icio.us Digg Technorati Blinklist Furl reddit

So one question comes to mind when thinking about my Rock Paper Scissors web service: is there any way I can improve the algorithm so I can win?

At first, it appears hopeless. If you take one “truly random” RPS player and pit him against another “truly random” RPS player, each player has a 50% chance of winning. Neither has any advantage, and so you are leaving the results of the game up to chance.

But what about non-random players? If you take an RPS player who always plays “Rock” and pit him against a “truly random” RPS player, each player still has a 50% chance of winning. The results of the game are also up to chance.

There should be a number of optimizations that I can add to my algorithm to recognize and defeat non-random players however. What if my opponent always plays “Rock”? I should be able to recognize that as a pattern and start playing “Paper”. In this situation, if I program it intelligently enough, I should be able to defeat any opponent who always plays the same move by a score of 20-2-3 over 25 games.

Thinking along the same lines, there are also other patterns besides the opponent who always plays the same move. What about opponents who cycle over the three moves in a predictable order? “Rock, Paper, Scissors, Rock, Paper, Scissors, Rock...” That's another pattern that can be looked for and effectively defeated.

Thinking about patterns, you can really go overboard, but why? So what if you test for a really complex pattern (like a Fibonacci series)? Noone is going to intentionally programm their RPS game to follow a Fibonacci series. Stick to the simple patterns - the ones lazy programmers are likely to use.

Finally, a word about odds and statistics. In any coin-flip scenario, the odds of each side of the coin are about even. If you flip a coin 1000 times, you will get heads about 500 times and tails about 500 times, plus or minus a relatively small range. That's odds.

Can you use this “even odds” to your advantage if you notice a player who's random RPS moves are a bit uneven? Can you “count cards” like a blackjack player? It's hard to tell. I'm going to do some more research and see if understanding the statistics of a game in progress can help you.

 

Thursday, May 20, 2004 9:24:05 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET
Del.icio.us Digg Technorati Blinklist Furl reddit

From Urs Muller's blog, I discovered that a Swiss web site is holding a programming contest to see who can develop the best Rock-Paper-Scissors web service. The web services will compete head-to-head, until only one web service remains as the winner. Wow, computer programming can be considered a sport. Olympics 2008 here we come!

(For those of you who missed this important part of childhood, here's how you play Rock-Paper-Scissors. It's a lot simpler than the Official Rules make it sound.)

Always looking for a small programming challenge, I decided to write a small ASP.NET Web Service. In a couple of hours, I had one done; I think I will enter it into the contest being held in June. There are some cool prizes -- so it would be nice to win. ;)

The Rock-Paper-Scissors Web Service I developed is here: http://www.mydemos.com/DemoSoftware/RPS/ScottRPS.asmx Of course, once the contest is over I will post the code here.

The first time I ran it against the test machine, I won 9 to 7. The second time, I won 9 to 8. Third time, I won 9-7 again.

 

Thursday, May 20, 2004 1:19:52 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET
Del.icio.us Digg Technorati Blinklist Furl reddit
Archive
<May 2004>
SunMonTueWedThuFriSat
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Scott Duffy
Sign In
Statistics
Total Posts: 470
This Year: 30
This Month: 0
This Week: 0
Comments: 73
Themes
Pick a theme:
All Content © 2008, Scott Duffy
DasBlog theme 'Business' created by Christoph De Baene (delarou)