Just a simple stones game, the person who picks the last stone loses. I plan on adding a scoreboard that will show up on the quad 7 segment LED's at the top. Also the computer has no intelligence, so I will add some code to give him strategic picks. 2 player hasn't been added yet, I will probably do that tomorrow. Crappy video recorded with my phone, but good enough that you can read the LCD screen.





Code:
// include the library code:
#include <LiquidCrystal.h>
#include <TrueRandom.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
//buttons
int take1 = 4;
int take2 = 5;
int take3 = 6;
//other variables
int showStartMenu = 1;
int menuChoice = 0;
int stonesInBucket;
int startOfGame = 1;
int computerStones;
int turn = 1;//0 for computer, 1 for player.

void setup() {
  pinMode(take1, INPUT_PULLUP);
  pinMode(take2, INPUT_PULLUP);
  pinMode(take3, INPUT_PULLUP);
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);
}

void loop(){
  if (showStartMenu == 1){
    menuChoice = startMenu(); 
  }
  if (menuChoice == 1){
    playGame();
  }
  if (menuChoice == 2){
    rules(); 
    showStartMenu = 1;
  }
}

int startMenu(){
  // Print a message to the LCD.
  lcd.setCursor(0, 0);
  lcd.print("Welcome to stones v1");
  lcd.setCursor(0, 1);
  lcd.print("   By MrOwnership   ");
  lcd.setCursor(0, 2);
  lcd.print("1: Play  3: 2 Player");
  lcd.setCursor(0, 3);
  lcd.print("2: Rules            "); 
  showStartMenu = 0;
  while(1){
    if (digitalRead(take1) == LOW){  //play button was pressed
      return 1;
    }
    if (digitalRead(take2) == LOW){
      return 2;
    }
  }
}

void playGame(){
  if (startOfGame == 1){
    stonesInBucket = TrueRandom.random(13, 20);
    startOfGame = 0;
  }
  if (stonesInBucket <= 0){
    endGame();
  } else if (stonesInBucket >= 10){
    lcd.setCursor(0, 0);
    lcd.print("There are ");
    lcd.setCursor(10, 0);
    lcd.print(stonesInBucket);
    lcd.setCursor(12, 0);
    lcd.print(" stones ");
    lcd.setCursor(0, 1);
    lcd.print("in the bucket.      ");
  } else if (stonesInBucket >=2 && stonesInBucket <= 9){
    lcd.setCursor(0, 0);
    lcd.print("There are ");
    lcd.setCursor(10, 0);
    lcd.print(stonesInBucket);
    lcd.setCursor(11, 0);
    lcd.print(" stones  ");
    lcd.setCursor(0, 1);
    lcd.print("in the bucket.      ");
  } else {
    lcd.setCursor(0, 0);
    lcd.print("There is ");
    lcd.setCursor(9, 0);
    lcd.print(stonesInBucket);
    lcd.setCursor(10, 0);
    lcd.print(" stone   ");
    lcd.setCursor(0, 1);
    lcd.print("in the bucket.      ");
  }
  if (turn == 1){
    playerTurn();
  } else {
    computerTurn(); 
  }
}
 
void playerTurn(){
  lcd.setCursor(0, 2);
  lcd.print("How many will you   ");
  lcd.setCursor(0, 3);
  lcd.print("take? 1, 2, or 3.   ");
  delay(1000);
  while(1){
    if(digitalRead(take1) == LOW){
      stonesInBucket -= 1;
      lcd.setCursor(0, 2);
      lcd.print("                    ");
      lcd.setCursor(0, 3);
      lcd.print(" You took 1 stone.  ");
      break;
    }
    if(digitalRead(take2) == LOW){
      stonesInBucket -= 2;
      lcd.setCursor(0, 2);
      lcd.print("                    ");
      lcd.setCursor(0, 3);
      lcd.print(" You took 2 stones. ");
      break;
    }
    if(digitalRead(take3) == LOW){
      stonesInBucket -= 3;
      lcd.setCursor(0, 2);
      lcd.print("                    ");
      lcd.setCursor(0, 3);
      lcd.print(" You took 3 stones. ");
      break;
    }
  }
  delay(2000);
  turn = 0;
  playGame();
}

void computerTurn(){
  computerStones = TrueRandom.random(1, 4);
  lcd.setCursor(0, 2);
  lcd.print("The computer has    ");
  if (computerStones == 1){
    lcd.setCursor(0, 3);
    lcd.print("taken 1 stone.      ");
  } else {
    lcd.setCursor(0, 3);
    lcd.print("taken ");
    lcd.setCursor(6, 3);
    lcd.print(computerStones);
    lcd.setCursor(7, 3);
    lcd.print(" stones.     ");
  }
  stonesInBucket -= computerStones;
  delay(2000);
  turn = 1;
  playGame();
}

void endGame(){
  if (turn == 0){//player looses
    lcd.setCursor(0, 0);
    lcd.print("The Computer has won");
    lcd.setCursor(0, 1);
    lcd.print("                    ");
    lcd.setCursor(0, 2);
    lcd.print("     Press 1 to     ");
    lcd.setCursor(0, 3);
    lcd.print("     play again     "); 
    while(1){
      if (digitalRead(take1) == LOW){
        break;
      }
    }
    resetGame();
  } else {
   
    lcd.setCursor(0, 0);
    lcd.print("      You win!      ");
    lcd.setCursor(0, 1);
    lcd.print("                    ");
    lcd.setCursor(0, 2);
    lcd.print("     Press 1 to     ");
    lcd.setCursor(0, 3);
    lcd.print("     play again     "); 
    while(1){
      if (digitalRead(take1) == LOW){
        break;
      }
    }
    resetGame();
  }
}


void resetGame(){
  stonesInBucket = 0;
  startOfGame = 1;
  turn = 1;
  playGame();
}

void rules(){
  lcd.setCursor(0, 0);
  lcd.print("-------Rules--------");
  lcd.setCursor(0, 1);
  lcd.print("Players alternate   ");
  lcd.setCursor(0, 2);
  lcd.print("taking stones out of");
  lcd.setCursor(0, 3);
  lcd.print("the bucket.");
  delay(5000);
  lcd.setCursor(0, 0);
  lcd.print("You can take up to 3");
  lcd.setCursor(0, 1);
  lcd.print("stones out per turn.");
  lcd.setCursor(0, 2);
  lcd.print("The player who takes");
  lcd.setCursor(0, 3);
  lcd.print("the last stone loses");
  delay(7000);
}
Stopwatch using an Arduino Uno