Author Topic: Tic-Tac-Toe (Grammer)  (Read 4628 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Tic-Tac-Toe (Grammer)
« on: January 16, 2012, 12:54:52 pm »
A new game to add to your Grammer collection is here! I still need to better the animation, optimise some code out, and make a menu so users can select options (such as who is the AI). Anyways, for now, there is an AI that you can play against, so have fun :)

When you finish the game, press clear to exit, press Enter to play again.

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #1 on: January 16, 2012, 12:59:47 pm »
how hard is the AI? does it make randomized mistakes except obvious wins?


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #2 on: January 16, 2012, 01:24:20 pm »
It is *supposed* to make like this:
Winning moves are always taken
Blocking an opponents winning move is taken if a winning move is not found
Random move if neither player can win next turn

So the AI is not amazing, but it works :)

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #3 on: January 16, 2012, 01:30:49 pm »
ahhh I see. yeah it's good enough AI for its purpose


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Tic-Tac-Toe (Grammer)
« Reply #4 on: January 16, 2012, 01:50:59 pm »
You could create a AI that can't lose! :D
* Sorunome knows how not to lose in tic tac toe

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #5 on: January 16, 2012, 01:52:25 pm »
really? id like to know how
This used to contain a signature.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #6 on: January 16, 2012, 01:52:38 pm »
For X, it is possible to never lose and for O, the same is true. However, there is a way to tie in either case. I am currently trying to make the algorithm in Grammer code >.>

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #7 on: January 16, 2012, 01:54:29 pm »
I haven't seen a tic tac toe game in a while!
This brings back some memories :D

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #8 on: January 16, 2012, 01:57:43 pm »
Okay, so the way I am going to do it, I will have 9, 8-byte lists for each of the 9 positions. there are 8 ways to win, so I will keep a running list of the current stats. I assign player X a value of 1 and player O a value of -1. The lists contain the win that get affected. When a potential win reaches -2, X will find a move that brings that to -1 (-3 is an O win, 3 is an X win), or if there is a 2, X will choose a move to bring that to 3 (if it exists).

Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: Tic-Tac-Toe (Grammer)
« Reply #9 on: January 16, 2012, 02:00:58 pm »
Wow, awesome game! Perhaps you could make a bigger board, like 4*4 or 5*5?

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Tic-Tac-Toe (Grammer)
« Reply #10 on: January 16, 2012, 02:01:48 pm »
really? id like to know how
if X starts in a corner...

X - -
- - -
 - -

then you do

X O -
- - -
- - -

If he does now

X O -
- - -
- - X
It's pretty easy and if oyu continue blocking wins there is a tie.

If he does
X O X
- - -
- - -

you do
X O X
- - O
- - -
and then again just block that he doesn't win ->tie

if he does:
X O -
- X -
- - -

OR

X O -
X - -
- - -
You just keep blocking his wins -> tie

if he does:
X O -
- - X
- - -

you do
X O -
O - X
- - -
and then just block his wins -> tie


Ok, if he now starts on the edge:
- X -
- - -
- - -

You do
- X -
- - -
O - -
and you can just block his winning moves -> tie

if he starts in the center he's really stupit as then you don't have to think and just have to block his winning moves -> tie.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!