Wednesday, February 22, 2006

Misc Stamp Programs

Misc Basic Stamp Programs



' {$STAMP BS2}
' {$PBASIC 2.5}

co_ambi VAR Word
cycle_L VAR Word
cycle_R VAR Word
I VAR Word
stride VAR Word
distance VAR Word

motor_R PIN 0
motor_L PIN 1
rc_L PIN 2
rc_R PIN 3
rc_ambi PIN 4
trigger PIN 5
recieve PIN 6

DIRA = %0011
DIRB = %0010

PAUSE 3000

DO
GOSUB charging
GOSUB direction
GOSUB drive
GOSUB avoid
LOOP
END

charging:
HIGH rc_ambi
PAUSE 100
RCTIME rc_ambi, 1, co_ambi
IF co_ambi = 1 THEN
DEBUG CLS
DEBUG "moving into light"
FOR stride = I TO 20
PWM motor_L, 255, 180
PWM motor_R, 255, 255
NEXT
LOW Motor_L
LOW Motor_R
DEBUG CLS
DEBUG "charging"
DO UNTIL co_ambi > 1
HIGH rc_ambi
PAUSE 100
RCTIME rc_ambi, 1, co_ambi
LOOP
ELSE
ENDIF
RETURN

direction:
HIGH rc_L
PAUSE 100
RCTIME rc_L, 1, cycle_L
HIGH rc_R
PAUSE 100
RCTIME rc_R, 1, cycle_R
DEBUG CLS
DEBUG ? co_ambi
DEBUG ? cycle_L
DEBUG ? cycle_R
RETURN

drive:
SELECT cycle_L
CASE < cycle_R
PWM motor_R, 255, 255
CASE > cycle_R
PWM motor_L, 255, 180
CASE = cycle_R
FOR stride = I TO 4
PWM motor_L, 255, 180
PWM motor_R, 255, 255
NEXT
ENDSELECT
LOW Motor_L
LOW Motor_R
RETURN

avoid:
HIGH trigger
PULSOUT trigger, 3
PULSIN recieve, 1, distance
SELECT distance
CASE < 800
IF cycle_L < cycle_R THEN
HIGH motor_R
LOW Motor_L
PAUSE 10000
ELSE
HIGH motor_L
LOW Motor_R
PAUSE 4000
ENDIF
ENDSELECT
LOW Motor_L
LOW Motor_R
DEBUG ? distance
RETURN




' {$STAMP BS2}
' {$PBASIC 2.5}

cs PIN 0 'chip select
clk PIN 1 'clock
setup PIN 2 'ADC setup
serial_D PIN 3 'serial data transfer pin
red PIN 12 'red LED
grn PIN 13 'grean LED
yel PIN 14 'yellow LED
shut_down PIN 11 'run pin

therm VAR Word 'variable for temperature data
ambient VAR Word 'variable for ambient temp data
pot VAR Word 'potentiometer counts 0-5 volts = 0-255 counts
I VAR Byte 'variable for counter
colors VAR OUTD 'variable output for LEDs

DIRA = %0111 'I/O declarations
DIRD = %0111

GOSUB flash_LEDs 'flashes 3 leds in a binary sequence red yel grn
GOSUB gather_ambient 'checks ambient temperature
DO WHILE shut_down = 1 'program will run untill = 0
GOSUB gather_DATA 'gathers serial byte of temperature data
GOSUB display 'displays temperature data
LOOP

DIRD = %0000

END

flash_LEDs: 'counts to 7 in binary with LED's
FOR colors = I TO 7
PAUSE 500
NEXT
PAUSE 1000
RETURN

gather_ambient: 'records ambient temperature
clk = 0
cs = 1
cs = 0
setup = 1 'specifies single ended mode
PAUSE 5
PULSOUT clk, 25
PAUSE 5
PULSOUT clk, 25
setup = 1 'tells ADC to use channel 0
PAUSE 5
PULSOUT clk, 25
PAUSE 5
SHIFTIN serial_d, clk, MSBPOST, [ambient\8]
ambient=ambient*2
DEBUG DEC ambient, " ambient temp in degrees C resolved to tenths"
DEBUG CR
RETURN

gather_data: 'gathers current temperature
clk = 0
cs = 1
cs = 0
setup = 1 'specifies single ended mode
PAUSE 5
PULSOUT clk, 25
PAUSE 5
PULSOUT clk, 25
setup = 0 'tells ADC to use channel 1
PAUSE 5
PULSOUT clk, 25
PAUSE 5
SHIFTIN serial_d, clk, MSBPOST, [pot\8]
pot = pot*2
DEBUG DEC pot, " pot counts in 'C' resolved to 1/10th of a degree"
DEBUG CR
clk = 0
cs = 1
cs = 0
setup = 1 'specifies single ended mode
PAUSE 5
PULSOUT clk, 25
PAUSE 5
PULSOUT clk, 25
setup = 1 'tells ADC to use channel 0
PAUSE 5
PULSOUT clk, 25
PAUSE 5
SHIFTIN serial_d, clk, MSBPOST, [therm\8]
cs = 1
therm=therm*2
DEBUG DEC therm, " temperature in degrees C resolved to tenths"
DEBUG CR
RETURN

display: 'select case led output, compares ambient to current
SELECT pot
CASE > therm
grn = 1
CASE < grn =" 0"> (ambient+50)
red = 1
DEBUG "Five degrees Above Ambient"
DEBUG CR
PAUSE 5000
CASE < (ambient-50) yel = 1 DEBUG "five degrees Below Ambient" DEBUG CR PAUSE 5000 CASE ELSE yel = 1 red = 1 PAUSE 250 yel = 0 red = 0 PAUSE 5000 ENDSELECT
RETURN








Tuesday, February 21, 2006

The Bird Watcher






' {$STAMP BS2}
' {$PBASIC 2.5}

time_code VAR Word
elapsed_seconds VAR Word
location VAR Word
retrieve_at VAR Word
i VAR Word
year VAR Word
month VAR Byte
day VAR Byte
day_logged VAR Byte
hour VAR Byte
start_hour VAR Byte
hour_logged VAR Byte
minute VAR Byte
start_minute VAR Byte
minute_logged VAR Byte
second VAR Byte
second_logged VAR Byte
add_comment VAR Nib
added_comment VAR Nib
press_1 VAR IN0
display_times VAR IN1
on_off VAR IN2

time_code = 0
location = 128
second = 0
minute = 0
hour = 0
day = 0
start_minute = 0
start_hour = 0


DO
IF on_off = 0 THEN
DEBUG "Enter Year (YYYY) "
DEBUGIN DEC year
DEBUG CR
DEBUG "Enter Month (MM) "
DEBUGIN DEC month
DEBUG CR
DEBUG "Enter Day (DD) "
DEBUGIN DEC day
DEBUG CR
DEBUG "Enter Hour (HH) "
DEBUGIN DEC start_hour
DEBUG CR
DEBUG "Enter Minut (MM) "
DEBUGIN DEC start_minute
DEBUG CR
DEBUG DEC4 year
DEBUG "-"
DEBUG DEC2 month
DEBUG "-"
DEBUG DEC2 day
DEBUG "-"
DEBUG DEC2 start_hour
DEBUG ":"
DEBUG DEC2 start_minute
DEBUG CR
DEBUG "Press the on_off switch at any time to start logging data"
DEBUG CR

minute = minute + start_minute
hour = hour + start_hour

waiting:

ENDIF

IF on_off = 1 THEN

PAUSE 990

second = second + 1
time_code = time_code + 1

IF second > 59 THEN
second = 0
minute = minute + 1
ENDIF

IF minute > 59 THEN
minute = 0
start_minute = 0
hour = hour + 1
ENDIF

IF hour > 24 THEN
hour = 1
start_hour = 0
day = day + 1
ENDIF

IF press_1 = 1 THEN
add_comment = 0

WRITE location, time_code.LOWBYTE
location = location + 1

WRITE location, time_code.HIGHBYTE
location = location + 1

WRITE location, day
location = location + 1

WRITE location, hour
location = location + 1

WRITE location, minute
location = location + 1

WRITE location, second
location = location + 1

WRITE location, add_comment
location = location + 1


ENDIF

IF display_times = 1 THEN
retrieve_at = 128

FOR i = 1 TO ((location - 128)/7)
READ retrieve_at, elapsed_seconds.LOWBYTE
retrieve_at = retrieve_at + 1

READ retrieve_at, elapsed_seconds.HIGHBYTE
retrieve_at = retrieve_at + 1

READ retrieve_at, day_logged
retrieve_at = retrieve_at + 1

READ retrieve_at, hour_logged
retrieve_at = retrieve_at + 1

READ retrieve_at, minute_logged
retrieve_at = retrieve_at + 1

READ retrieve_at, second_logged
retrieve_at = retrieve_at + 1

READ retrieve_at, added_comment
retrieve_at = retrieve_at + 1

DEBUG DEC ? elapsed_seconds
DEBUG CR
DEBUG DEC4 year
DEBUG "-"
DEBUG DEC2 month
DEBUG "-"
DEBUG DEC2 day_logged
DEBUG "-"
DEBUG DEC2 hour_logged
DEBUG ":"
DEBUG DEC2 minute_logged
DEBUG "."
DEBUG DEC2 second_logged
DEBUG CR
DEBUG DEC ? added_comment
DEBUG CR
DEBUG "*****************************************"
DEBUG CR
NEXT
ENDIF
ELSE
GOTO waiting
ENDIF
LOOP

C++ Programs

#include
#include
#include
using namespace std;
int main()
{
cout << "\n\nWould you like to go to the zoo with me today?\n\n";
inline char ask_yes_no();
char yes_or_no = ask_yes_no();
{
if (yes_or_no == 'y')
{
cout << "\nFantastic! I love the zoo," << " ";
cout << "I am so excited to go with you.\n\n";
}
if (yes_or_no == 'n')
{
cout << "\nThat is dissapointing, Im so sad.\n\n";
}
}
cout << "How about a game of chess?\n\n";
cout << "Just kidding, I do not know how to play chess yet.\n\n";
cout << "How about a nice game of tic-tac-toe?\n\n";
yes_or_no = ask_yes_no();
{
if (yes_or_no == 'y')
{
char tic_tac();
char victor = tic_tac();
{
if (victor == 'X')
{
cout << "I guess X won, unless you are lying\n\n";
}
else
{
cout << "O must have won, unless you lied to me\n\n.";
}
}
}
}
cout << "\nWould you like to calculate test grades?\n\n";
yes_or_no = ask_yes_no();
{
if (yes_or_no == 'y')
{
float test_grader();
float average = test_grader();
{
if (average >= 90)
{
cout << "The class average is an A\n\n";
}
if (average < 90 && average >= 80)
{
cout << "The class average is a B\n\n";
}
if (average < 80 && average >= 70)
{
cout << "The class average is a C\n\n";
}
if (average < 70 && average >= 60)
{
cout << "The class average is a D\n\n";
}
if (average <= 59)
{
cout << "The class average is an F\n\n";
}
}
}
}
cout << "\nThis program can also spell words backwards,";
cout << "would you like that?\n\n";
yes_or_no = ask_yes_no();
{
if (yes_or_no == 'y')
{
string reverser();
string any_thing = reverser();
{
cout << any_thing << " was the word initially Right?";
cout << "\n\n";
}
}
}
cout << "You have reached the end of the program, I hope you had fun.\n";
system("pause");
return 0;
}
char ask_yes_no()
{
char yes_or_no;
do
{
cout << "(y/n)" << " ";
cin >> yes_or_no;
}
while (yes_or_no != 'y' && yes_or_no != 'n');
return yes_or_no;
}
char tic_tac()
{
int rw = 0;
int clm = 0;
const int ROWS = 4;
const int COLUMNS = 4;
char quit;
char victor;
string whose_move;
string O_s_move;
string X_s_move;
do
{
char board[ROWS][COLUMNS] = {{' ', '1', '2', '3'},
{'1', 'E', 'E', 'E'},
{'2', 'E', 'E', 'E'},
{'3', 'E', 'E', 'E'}};
cout << "\n\n";
for (int i = 0; i < ROWS; ++i)
{
for (int j = 0; j < COLUMNS; ++j)
cout << "\t" << board[i][j];
cout << endl;
}
for (int c = 0; c < 5; c++)
{
if (whose_move != "O_s_move")
{
cout << "\nX's move.\n";
cout << "\nenter ROW (1-3), and COLUMN (1-3)\n";
cin >> rw >> clm;
if (board[rw][clm] == 'X' || board[rw][clm] == 'O')
{
cout << "\n\n'X' made an illeagle move!\n\n";
continue;
}
board[rw][clm] = 'X';
cout << "\nNow the tic-tac-toe board is:\n\n";
for (int i = 0; i < ROWS; ++i)
{
for (int j = 0; j < COLUMNS; ++j)
cout << "\t" << board [i][j];
cout << endl;
}
}
if (board[1][1] == 'X' && board[1][2] == 'X' && board[1][3] == 'X'
|| board[2][1] == 'X' && board[2][2] == 'X' && board[2][3] == 'X' ||
board[3][1] == 'X' && board[3][2] == 'X' && board[3][3] == 'X' ||
board[1][1] == 'X' && board[2][1] == 'X' && board[3][1] == 'X' ||
board[1][2] == 'X' && board[2][2] == 'X' && board[3][2] == 'X' ||
board[1][3] == 'X' && board[2][3] == 'X' && board[3][3] == 'X' ||
board[1][1] == 'X' && board[2][2] == 'X' && board[3][3] == 'X' ||
board[1][3] == 'X' && board[2][2] == 'X' && board[3][1] == 'X')
{
cout << "\n\n'X' won the game!\n\n";
break;
}
if (c == 4)
{
cout << "\n\nThe game was a tie.\n\n";
break;
}
cout << "\nO's move.\n";
cout << "\nenter ROW (1-3), and COLUMN (1-3)\n";
cin >> rw >> clm;
if (board[rw][clm] == 'X' || board[rw][clm] == 'O')
{
cout << "\n\n'O' made an illeagle move!\n\n";
whose_move = "O_s_move";
continue;
}
board[rw][clm] = 'O';
whose_move = "X_s_move";
cout << "\nNow the tic-tac-toe board is:\n\n";
for (int i = 0; i < ROWS; ++i)
{
for (int j = 0; j < COLUMNS; ++j)
cout << "\t" << board [i][j];
cout << endl;
}
if (board[1][1] == 'O' && board[1][2] == 'O' && board[1][3] == 'O'
|| board[2][1] == 'O' && board[2][2] == 'O' && board[2][3] == 'O' ||
board[3][1] == 'O' && board[3][2] == 'O' && board[3][3] == 'O' ||
board[1][1] == 'O' && board[2][1] == 'O' && board[3][1] == 'O' ||
board[1][2] == 'O' && board[2][2] == 'O' && board[3][2] == 'O' ||
board[1][3] == 'O' && board[2][3] == 'O' && board[3][3] == 'O' ||
board[1][1] == 'O' && board[2][2] == 'O' && board[3][3] == 'O' ||
board[1][3] == 'O' && board[2][2] == 'O' && board[3][1] == 'O')
{
cout << "\n\n'O' won the game!\n\n";
break;
}
}
cout << "\n\nDo you wish to quit? (y/n)\n\n";
cin >> quit;
do
{
cout << "\n\nWho won, (X/O)?";
cin >> victor;
}
while (victor != 'X' && victor != 'O');
}
while (quit == 'n');
return victor;
}
float test_grader()
{
string student_name;
int row0 = 0;
int row1 = 0;
float average = 0;
float buffer = 0;
float total = 0;
const int ROW0 = 30;
const int ROW1 = 30;
string name_matrix[ROW0];
float score_matrix[ROW1];
float score = 0;
float student_number = 0;
cout << "\nTo beging entering test scores press any key\n";
cin.get();
cout << "\n0 as a student test score = 'quit'.\n";
cout << "\nUse an underscore to seperate first and last names.\n";
do
{
student_number++;
cout << "\nEntry number: " << student_number;
cout << "\n\nEnter test score in %.\n";
cin >> score;
score_matrix[row1] = score;

if (score > 100 || score < 0)
{
cout << "\n\nInvalid data type\n\n";
system ("pause");
student_number = 0;
continue;
}
row1++;
if (score == 0)
break;
cout << "\nEnter student name\n";
cin >> student_name;
name_matrix[row0] = student_name;
++row0;
}
while (true);
row0 = 0;
row1 = 0;
for (int j = 0; j <= student_number - 2; j++)
{
cout << "\n\n" << name_matrix[row0] << " scored a ";
cout << score_matrix[row1] << "%";
cout << "\n" << name_matrix[row0];
if (score_matrix[j] >= 90)
{
cout << " got an A\n\n";
}
if (score_matrix[j] < 90 && score_matrix[j] >= 80)
{
cout << " got a B\n\n";
}
if (score_matrix[j] < 80 && score_matrix[j] >= 70)
{
cout << " got a C\n\n";
}
if (score_matrix[j] < 70 && score_matrix[j] >= 60)
{
cout << " got a D\n\n";
}
if (score_matrix[j] <= 59)
{
cout << " got a F\n\n";
}
row0++;
row1++;
}
for (row1 = 0; row1 <= student_number - 2; row1++)
{
total = buffer + score_matrix[row1];
buffer = total;
}
average = total / (student_number - 1);
cout << "\n\nAverage score: " << average << "\n\n";
return average;
}
string reverser()
{
string any_thing;
cout << "Enter a string\n\n";
cin >> any_thing;
cout << "\n";
for (int i = any_thing.length() - 1; i >= 0; i--)
{
cout << any_thing[i];
}
cout << " is " << any_thing << " spelled backwards.\n\n";
return any_thing;
}


// Theta and
// The Fibonocci Sequence;

//up to 9.28565e+4931; or the 23601st element.
#include
using std::cin;
using std::cout;
int main()
{
unsigned long order = 0;
long double a_1 = 1;
long double a_2 = 1;
long double a_next;
long double theta;
long double dump = 0;
long double dump2;
char decision;
cout << "Press return to get the Fibonocci Sequence going";
cin.get();
order++;
cout << "\t\t" << order << ") " << a_1 << "\n";
order++;
cout << "\t\t" << order << ") " << a_2 << "\n";
theta = a_2 / a_1;
dump2 = theta + dump;
dump = dump2;
do
{
for (int i = 0; i < 255; i++)
{
a_next = a_1 + a_2;
theta = a_2 / a_1;
dump2 = theta + dump;
dump = dump2;
order++;
cout << "\t\t" << order << ") " << a_next << "\n";
a_1 = a_2;
a_2 = a_next;
}
cout << "current average of Theta: " << dump / (order - 1);
cout << "\nlast computed Theta: " << a_next / a_1;
cout << "\n\tQuit? (y/n)";
cin >> decision;
}
while (decision != 'y');
cout << "\noverall average of Theta: " << dump / (order - 1);
cout << "\nlast computed value of Theta: " << a_next / a_1;
cout << "\nI'm sorry that is as high as I can calculate the sequence\n";
cout << "press return to quit";
cin.get();
return 0;
}



// Lock Combination. Nested if.
#include
using namespace std;
int main()
{
const int first_num = 25;
const int second_num = 30;
const int third_num = 88;
int first_pick;
int second_pick;
int third_pick;
cout << "\n\nEnter first number.\n\n";
cin >> first_pick;
if (first_pick == first_num)
{
cout << "\n\nNow enter second pick.\n\n";
cin >> second_pick;
if (second_pick == second_num)
{
cout << "\n\nNow enter third pick.\n\n";
cin >> third_pick;
if (third_pick == third_num)
{
cout << "\n\nYou opened the combination lock!\n\n";
}
}
}
else
{
cout << "\n\nThis lock does not belong to you.\n\n";
}
return 0;
}



// Lock Combination
#include
using namespace std;
int main()
{
const int first_num = 25;
const int second_num = 30;
const int third_num = 88;
int first_pick;
int second_pick;
int third_pick;
cout << "\n\nenter first number\n\n";
cin >> first_pick;
cout << "\n\nnow enter second pick\n\n";
cin >> second_pick;
cout << "\n\nnow enter third pick\n\n";
cin >> third_pick;
if (first_pick == first_num && second_pick == second_num &&
third_pick == third_num)
{
cout << "\n\nI cant believe it,";
cout << "you opened the combination lock\n\n";
}
else
{
cout << "\n\nthis lock does not belong to you\n\n";
}
return 0;
}



//The Keno Player. With help from Jim
#include
#include
#include
#include
using namespace std;
int main()
{
srand(time( 0 ));
int random_number;
int pick;
string answer;
bool done = false;
while (!done)
{
random_number = rand();
pick = (random_number % 80) + 1;
cout << "\n\npick:" << "\t" << pick << "\n\n";
cout << "\n\nDo you want another value? (yes/no)\n\n";
cin >> answer;
if ( answer != "yes" )
done = true;
}
return 0;
}



//prime number finder 2.0
#include
#include
#include
using namespace std;
int main()
{ofstream fout("primes.txt");
float stop = 0;
int place = 0;
const int size = 100000;
cout << "\nEnter ending number of primes calculation\n";
cin >> stop;
float testedNums[size];
float primeNums[size];
stop++;
primeNums[place] = 1;
testedNums[place] = place;
place++;
time_t start = time(0);
for(float allNums = 2; allNums <= stop; allNums++)
{float twoForPrime = 0;
for(float divNum = 1; divNum <= stop; divNum++)
{float tested = allNums / divNum;
int logicLow = tested - 1;
int logicHigh = tested + 1;
for(float testNum = logicLow; testNum <= logicHigh; testNum++)
{if(tested == testNum)
twoForPrime++;}}
if(twoForPrime == 2)
{primeNums[place] = allNums;
testedNums[place] = place;
place++;}}
time_t end = time(0);
for(int i = 0; i < place; i++)
{cout << testedNums[i] + 1 << " " << primeNums[i] << endl;
fout << testedNums[i] + 1 << " " << primeNums[i] << endl;}
cout << "\nElapsed seconds: " << difftime(end, start) << endl;
fout << flush;
fout.close();
return 0;}




// Tic Tac Toe Board 3.0 AI
#include
#include
using namespace std;
int main()
{srand(time(0));
int rw = 0;
int clm = 0;
const int ROWS = 4;
const int COLUMNS = 4;
char quit;
string whose_move;
string O_s_move;
string X_s_move;
do
{char board[ROWS][COLUMNS] = {{' ', '1', '2', '3'},
{'1', 'E', 'E', 'E'},
{'2', 'E', 'E', 'E'},
{'3', 'E', 'E', 'E'}};
cout << "\n\n";
for (int i = 0; i < ROWS; ++i)
{for (int j = 0; j < COLUMNS; ++j)
cout << "\t" << board[i][j];
cout << endl;}
for (int c = 0; c < 5; c++)
{if (whose_move != "O_s_move")
{cout << "\nX's move.\n";
cout << "\nenter ROW (1-3), and COLUMN (1-3)\n";
cin >> rw >> clm;
if (board[rw][clm] == 'X' || board[rw][clm] == 'O')
{cout << "\n\n'X' made an illeagle move!\n\n";
continue;}
board[rw][clm] = 'X';
cout << "\nNow the tic-tac-toe board is:\n\n";
for (int i = 0; i < ROWS; ++i)
{for (int j = 0; j < COLUMNS; ++j)
cout << "\t" << board [i][j];
cout << endl;}}
if (board[1][1] == 'X' && board[1][2] == 'X' && board[1][3] == 'X'
|| board[2][1] == 'X' && board[2][2] == 'X' && board[2][3] == 'X' ||
board[3][1] == 'X' && board[3][2] == 'X' && board[3][3] == 'X' ||
board[1][1] == 'X' && board[2][1] == 'X' && board[3][1] == 'X' ||
board[1][2] == 'X' && board[2][2] == 'X' && board[3][2] == 'X' ||
board[1][3] == 'X' && board[2][3] == 'X' && board[3][3] == 'X' ||
board[1][1] == 'X' && board[2][2] == 'X' && board[3][3] == 'X' ||
board[1][3] == 'X' && board[2][2] == 'X' && board[3][1] == 'X')
{cout << "\n\n'X' won the game!\n\n";
break;}
if (c == 4)
{cout << "\n\nThe game was a tie.\n\n";
break;}
do
{cout << "\nO's move.\n";
rw = (rand() % 3) + 1;
clm = (rand() % 3) + 1;
if (board[2][2] == 'E')
rw = 2, clm = 2;
if (board[rw][clm] == 'X' || board[rw][clm] == 'O')
{whose_move = "O_s_move";
continue;}
board[rw][clm] = 'O';
whose_move = "X_s_move";
cout << "\nNow the tic-tac-toe board is:\n\n";
for (int i = 0; i < ROWS; ++i)
{for (int j = 0; j < COLUMNS; ++j)
cout << "\t" << board [i][j];
cout << endl;}}
while (whose_move == "O_s_move");
if (board[1][1] == 'O' && board[1][2] == 'O' && board[1][3] == 'O'
|| board[2][1] == 'O' && board[2][2] == 'O' && board[2][3] == 'O' ||
board[3][1] == 'O' && board[3][2] == 'O' && board[3][3] == 'O' ||
board[1][1] == 'O' && board[2][1] == 'O' && board[3][1] == 'O' ||
board[1][2] == 'O' && board[2][2] == 'O' && board[3][2] == 'O' ||
board[1][3] == 'O' && board[2][3] == 'O' && board[3][3] == 'O' ||
board[1][1] == 'O' && board[2][2] == 'O' && board[3][3] == 'O' ||
board[1][3] == 'O' && board[2][2] == 'O' && board[3][1] == 'O')
{cout << "\n\n'O' won the game!\n\n";
break;}}
cout << "\n\nDo you wish to continue? (y/n)\n\n";
cin >> quit;}
while (quit != 'n');
return 0;}