imout
January 4, 2024, 6:05pm
108
Here’s my code solution! Not sure if this forum is alive still but felt good about finishing this one (and by the looks of it a bit differently from everyone else).
Hey im looking at your code to help me understand a bit better and I wanted to know if you could explain this section to me.
void gridPosition()
{
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++){
std::cout << "|" << ((i*3)+j+1) << "|";
};
std::cout << "\n";
};
}
That’s pretty encouraging to hear, and I’m glad you made it through! I tried to churn this out in 2 hours and felt like a failure. But I’ll keep pressing on!
Hey @andrew_thomas I believe they are using a 2D Array iteration to create their Tic-Tac-Toe grid? Just judging by what I’m looking at, and not sure if the OP replied.
I think this one is done.
This was fun
can’t wait for the next challenge
https://github.com/gregorycarnegie/tic_tac_toe
First game done : )
My brain was hopping around on this, let’s hope there aren’t too many bugs
ttt.cpp
#include <iostream>
#include <vector>
#include "func.hpp"
int main(){
bool play = true;
while (play){
std::string player_one;
std::string player_two;
std::string turn;
This file has been truncated. show original
ttt_f.cpp
#include <iostream>
#include <vector>
void player_intro(int i, std::string player_one, std::string player_two){
if (i==0){
std::cout << player_one << ": \n";
}
else{
std::cout << player_two << ": \n";
This file has been truncated. show original
ttt_f.hpp
//void board_change(std::string row, char player, int i);
void intro(std::string &player_one, std::string &player_two);
void player_intro(int i, std::string player_one, std::string player_two);
int board_state_column(char column);
std::string board_change(std::string row, char player, char i);
bool check_place(std::string row, char y);
This file has been truncated. show original
Here’s my code on GitHub, feedback is appreciated. Thank you
Here is my very basic Tic Tac Toe game. Less then 80 lines, but it seems to work.
this is a codecadamy project for a very basic tic tac toe game
Please let me know if you find any issues.
A simple Tic Tac Toe game attempt on C++
I made some effort , put some extra reading for references and then tried to apply. It works with occasional errors that I think are beyond my scope now. I made this public please review and suggest as you wish. Thank you .
ttt.cpp
#include <iostream>
#include <vector>
#include "ttt.hpp"
int main() {
int current_player = 1;
int player_choice;
bool board_filled = false;
bool game_won = false;
int winner;
This file has been truncated. show original
ttt.hpp
#include <vector>
void display_board(std::vector<std::string>);
void place_mark(int, int, std::vector<std::string>&, std::vector<std::string>&);
void check_wins_straights(std::vector<std::string>, bool&, int&);
void check_wins_diagonals(std::vector<std::string>, bool&, int&);
This file has been truncated. show original
ttt_funcs.cpp
#include <iostream>
#include <vector>
void display_board(std::vector<std::string> board) {
std::cout << board[0] << " | " << board[1] << " | " << board[2] << "\n";
std::cout << "--+---+--\n";
std::cout << board[3] << " | " << board[4] << " | " << board[5] << "\n";
std::cout << "--+---+--\n";
std::cout << board[6] << " | " << board[7] << " | " << board[8] << "\n";
}
This file has been truncated. show original
I really like the final product I ended up with. This was a fun challenge!
1 Like
Awesome! Thanks for sharing! We enjoyed playing this in class.