Share your repls and programming experiences

← Back to all posts
First Rust Program!!
h
Coder100 (17090)

Tic-Tac-Toe

The classic tic-tac-toe game has been implemented by me with a brand new design in RUST!

About

Lately, I have been learning rust because it's pretty cool... It has the speed of C++, but also with the pleasant features of higher-level languages like js and haskell. Together, this epik language was made. Yay!

I never actually made anything useful while learning the language, but now I have! This tic-tac-toe game is to practice my rust skills :))

Screenshots

How to play

Step 1. Press that big green button
Step 2. Enter in the x and y position

Step 3. Try to win!

Credits

Special thanks to @frissyn for judging me.
Special thanks to @flaminhotvaldez for showing me the strategy behind tic-tac-toe

Updates

There is now an AI, albeit dumb

Closing

I hope you enjoy playing this as much as I did making it! A little code review wouldn't be bad either :)

Comments
hotnewtop
[deleted]

Me: creates a GUI of tic tac to game
evry1: We don't care
@Coder100: Created a console tic tac toe game
evry1: WOW!! Let's upvote!

X24 (28)

@Hacky You have summarised life.

[deleted]

ppl only care fur da popular

Coder100 (17090)

i don't know what that means but thanks? @Hacky

[deleted]

...

programmeruser (571)

@Hacky how is the terminal inferior to GUIs?

tussiez (1526)

@Hacky How could you say something so controversial yet so brave?
Facts

Coder100 (17090)

i like how he thinks people upvote popular programs but don't actually justify why @tussiez

Coder100 (17090)

what is the justification @tussiez

tussiez (1526)

@Coder100 This is normal human behavior, we are just complaining. Do not worry

FlaminHotValdez (442)

Can you please add an AI to play against? Because I have no friends of Covid I have no one to play it with :(

FlaminHotValdez (442)

@Coder100 I mean the classic tictactoe ai is like this: If you can win, win. If you can't win and the other guy can, block him. Otherwise if the center is available take the center. Otherwise if the corner is available take the corner. Otherwise take the side. That being said I honestly don't know any good way to check whether you can win or if the other guy can win without spamming a ton of or statements.

Coder100 (17090)

alright
here goes

if center_available() {
  yeet_the_center()
}

if let Some(corner) = corner_available() {
  yeet_the_corner(corner);
}

if let Some(edge) = edge_available() {
  yeet_the_edge(edge);
}

// done!

@FlaminHotValdez

FlaminHotValdez (442)

@Coder100 Also check whether you can win. If you can win, win. And if the other guy can win, block him.

Coder100 (17090)

lol that part will require some more analyses that I'm not really sure I want to do xd @FlaminHotValdez

FlaminHotValdez (442)

@Coder100 lol...I had to spam if statements.

programmeruser (571)

It has the speed of C++, but also with the pleasant features of higher-level languages like js and haskell. Together, this epik language was made. Yay!

What do you mean?
C++ also has high level features.

Coder100 (17090)

@programmeruser yes, they do, but is it really pleasant to use?
std::tuple for example

[deleted]

coool

maxina (46)

NICE! Although I will say the bot is pretty easy hehe

firedragondnd (46)

I gave you your 13400 th upvote! What an honor . lol 😜

robowolf (446)

@Coder100 First, sorry for the ping, second I'm doing this thing called Replit Unsolved, since you have a lot of cycles I was wondering if you could answer this question. What are some things that you do to get a repl trending? P.S You don't have to answer if you don't want to.

robowolf (446)

@Coder100 Code...presentation. Anything. Just what do you do to make a great repl.

Coder100 (17090)

hm

headers

how about that @robowolf

Coder100 (17090)

tbh i don't know myself @robowolf

robowolf (446)

@Coder100 Lol. Headers are pog tho so...

X24 (28)

@robowolf You just need a good idea, a nice post that people will understand, hard work and the community should love it. This game was a good idea, Coder100 made a clear post, they worked hard on it and the post is on trending.

BananaJellyfish (206)

This ai is almost as dumb as me

FlaminHotValdez (442)

yey coder admitted c++ is fast yeehaw we have approval all c++ coders yey

ChristopherDai (81)

good job
but I suggest you can detect if I'm only typing 1 number, 1 to 9. It only has 9 slots so yeah

RhinoRunner (833)


Pretty cool!

Maybe make it so the screen clears when you make your move?

Coder100 (17090)

alright, fair enough, that's the third request today. I'll add it @RhinoRunner

Whippingdot (572)

Nice Game. Clear the screen after a move tho, that would be nice.

Coder100 (17090)

yeah, i'm trying to find some way to do that in rust @Whippingdot

Whippingdot (572)

The circled is what the AI just placed:


AI dumb boi

acccount (3)

Its slightly confusing, maybe change it so one side is letters? Smth like this maybe.
1 2 3
a
b
c