Hi everyone!  This is my first instructable!

This is a REAL self - learning robot that learns how to play rock - paper - scissors!  It will learn how to beat a person 100% of the time!  A person is NOT needed to teach the robot how to play the game; it really does learn by itself!  

This robot does not play rock-paper-scissors in the way people play.  It first asks the user to input a move (either rock - paper - or scissors).  The robot then calculates the best move to play, and then will extend a retractable arm that shows its next move (a Lego rock, paper, or a Lego scissors).  The player must then tell the robot if the robot won, lost, or tied, against the player.  

While you may think that this robot is cheating, since it waits for the player to make a move, I did not program the robot to know the rules of the game!  The robot does not know that rock beats scissors, paper beats rock, or scissors beats paper!  Instead, the robot relies on the player to tell whether it won/lost/tied to learn from past success/failures and to use this information in the future!

This robot was featured at Robogames 2011 for the Lego Open challenge (first place!).  Moar pics and the source code will be attached!

Step 1: You Shall Not Win! - Construction Overview

The robot is made out of the following pieces:

1x Lego Mindstorms NXT - the brain!
3x Lego Mindstorms Touch Sensors - User Inputs
3x Lego Mindstorms NXT Motors - Peripherals for the robot
Tetrix Pieces for the Base (Aluminum chassis)

This robot has a very simple construction; each motor drives a retractable arm that carries a Lego rock (left), paper (center, I didn't have any Lego paper handy!), and scissors (right).  The robot will extend the arm that indicates its move.

On the bottom of the robot is the user inputs, which are three touch sensors with gears on them.  Each sensor has two possible options.  

Left Sensor: Rock and Yes!
Center Sensor: Paper and No!
Right Sensor: Scissors and Tie!

I will explain why each sensor has two options in the next slide!

I just read through all of the code and your reward system is pointless. it does nothing except have a variable set to 1 or -10000. the the only time it uses the reward variable is when setting it. there is nothing that tells it that 1 is good or -10000 is bad. please correct me if I'm wrong.
I'm very sorry, I just checked again and I somehow missed the point where it uses reward to update qscore or something like that. I don't know how I missed it I even searched for it and didn't see it.
very cool! I would appreciate it if you made a separate instructable going into the program and how that in particular works I find it very interesting and you seem to have it figured out.
WARGAMES!!!!!!!!!! next you should make a robot to play tic tac to with one zero players <br>
You mentioned a 'reward points' system to encourage the robot to learn. But what would you do if the robot came to realize that the reward points were really meaningless, and started just messing with the human (always getting a tie, for instance?). This robot doesn't seem like it could take over the world or anything, but it might try.
I guess we're all screwed then! :D <br><br>Actually the program CAN tie with a person.... you just need to add an extra if statement in the code:<br><br> if((i == 0 &amp;&amp; j == 0) || (i == 0 &amp;&amp; j == 2) || (i == 1 &amp;&amp; j == 0) || (i == 1 &amp;&amp; j == 1) || (i == 2 &amp;&amp; j ==1) || (i == 2 &amp;&amp; j == 2))<br> {<br> reward = -10000;<br> }//end if<br> <br> //otherwise, the robot must win; reward it with a virtual point!<br> else<br> {<br> reward = 1;<br> }//end else<br><br>Change this to:<br>if((i == 0 &amp;&amp; j == 2) || (i == 1 &amp;&amp; j == 0) || (i == 2 &amp;&amp; j == 1))<br>{<br> reward = -10000; //For losing against human, lose 10K points!<br>}<br>else if((i == 0 &amp;&amp; j == 0) || (i == 1 &amp;&amp; j == 1) || (i == 2 &amp;&amp; j == 2))<br>{<br> reward = 1; //1 point for tying<br>}<br>else<br>{<br> reward = 1; //1 point for winning<br>}<br><br>This way, the robot might tie or might decide to win, depending on how it's feeling :D I tested out this code before, and most of the time, it prefers to win....
<br> Interesting.&nbsp; It's simulating a simple neural network.<br> There are<a href="http://webdocs.cs.ualberta.ca/~darse/rsbpc.html"> programs around </a>which will learn the quirks and frequencies of the person (or algorithm) it's playing against and make a good guess as to what they are going to play next.&nbsp; That could be something to work towards.<br> Also, what's the range of the NXT colour sensor?&nbsp; You could possibly use one to detect if the human was holding up a rock, scissors or paper marked with an appropriate colour.<br> <sup>(BTW, the word is 'more'.)</sup><br>
Hi!<br><br>Which color sensor are you referring to? The Retail 2.0 one can only see 6 colors: White/Black/Green/Red/Yellow/Blue, but the Hitechnic one (both 1.0 and 2.0) can see 17 different shades. I think it's 2 each of Red-Orange-Yellow-Green-Blue-Indigo-Purple, and Black/Gray/White.<br><br>That's an interesting option... reducing the number of sensors from 3 Touch to 1 Color! I think people liked pushing buttons more, so I chose the buttons over the color sensor!
<strong>&nbsp; </strong><br> I'm not that familiar with the NXT accessories but I knew there was (at least) one colour sensor.&nbsp; Of course you'd only need to differentiate three colours here.&nbsp; Fair enough if people prefer pushing buttons though.<br>
Oops, forgot to mention the outputs!<br><br>Rock - Left Motor - Port A<br>Paper - Center Motor - Port B<br>Scissors - Right Motor - Port C<br><br>Left Touch - Port 1<br>Center Touch - Port 2<br>Right Touch - Port 3

About This Instructable




Bio: Been a while since I've been on here! Now a Robotics Software Engineer at Neato Robotics.
More by prrgg14935:Self-Learning Rock - Paper - Scissors Robot from Lego Mindstorms NXT! 
Add instructable to: