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!
Remove these ads by
Signing UpStep 1: You shall not win! - Construction Overview
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!






































Visit Our Store »
Go Pro Today »




Actually the program CAN tie with a person.... you just need to add an extra if statement in the code:
if((i == 0 && j == 0) || (i == 0 && j == 2) || (i == 1 && j == 0) || (i == 1 && j == 1) || (i == 2 && j ==1) || (i == 2 && j == 2))
{
reward = -10000;
}//end if
//otherwise, the robot must win; reward it with a virtual point!
else
{
reward = 1;
}//end else
Change this to:
if((i == 0 && j == 2) || (i == 1 && j == 0) || (i == 2 && j == 1))
{
reward = -10000; //For losing against human, lose 10K points!
}
else if((i == 0 && j == 0) || (i == 1 && j == 1) || (i == 2 && j == 2))
{
reward = 1; //1 point for tying
}
else
{
reward = 1; //1 point for winning
}
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....
Interesting. It's simulating a simple neural network.
There are programs around 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. That could be something to work towards.
Also, what's the range of the NXT colour sensor? You could possibly use one to detect if the human was holding up a rock, scissors or paper marked with an appropriate colour.
(BTW, the word is 'more'.)
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.
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!
I'm not that familiar with the NXT accessories but I knew there was (at least) one colour sensor. Of course you'd only need to differentiate three colours here. Fair enough if people prefer pushing buttons though.
Rock - Left Motor - Port A
Paper - Center Motor - Port B
Scissors - Right Motor - Port C
Left Touch - Port 1
Center Touch - Port 2
Right Touch - Port 3