You are not logged in.
Greetings fellow archers!
In an effort to do something productive, and thwart my depression issues, I've gotten back into programming. It's something I enjoy and, for my skill level (occasional hobbyist), I think it's something I'm good at. So I made an open ended repository of CLI games that I'm working on. Currently it's just Tic Tac Toe. My goal is to include hangman, some sort of word chain game, and possibly yahtzee. I do plan on making AI for all of my games. Hopefully I can get a career within ~4 years if I like coding enough. Games are written in C++ but I may add Lua support in the distant future.
The link to my repository is: https://github.com/JohnBobSmith/console_games
I'm currently challenging myself to use just a text editor, terminal, and Makefile. I find it actually simplifies things, though Code::Blocks is nice.
Basically, if anyone wants to help with my games in any way, or give me feedback, it'd be much appreciated . Otherwise, I thought it couldn't hurt to post it here for sake of giving back, in my own way, to the free software community.
Best wishes to all,
JohnBobSmith
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline
Although the lack of replies is a tad disappointing, work continues on tic tac toe. I now consider 2 human player games fully playable. I've also added proper help text, and what not. If I get no responses on this thread from this post on, I'll leave it alone. My side projects and related blog-like updates should be on just that. A blog.
Thank you to the ~40 visitors to my github repo though! It means a lot to me.
Happy coding,
JohnBobSmith
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline
JohnBob this will be a great learning experience so don't give up. However the games you are building have been around for a long time and have many implementations. When you feel sure enough to try something original I'm sure there will be more interest.
Offline
Hm... While I don't disagree with you, I feel like it would be hard to come up with anything truly original. Though after I finish my tic tac toe, I'll be sure to keep that in mind.
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline
You just started.
Me have an (almost) finished product, and (still) get no replies.
Do it for your own fun, regardless what others say.
Keep it up, after all, you learn C anyway
For practice...
Try writing a function (for each task) you currently write the very same for Player1 and for Player2, instead, pass the player as a variable (sort of).
(eg: game.isvictory() )
Happy coding!
EDIT:
I mean something in the like of: (simplified)
int game.has_won(plyr)
{
std::cout << "\n\n" .. plyr .. " wins!\n\n";
std::cout << "Now exiting on grounds of happy victory ;)\n\n";
return 0;
}
if (game.is_victory(player2.playerPiece)) {
game.has_won(player2)
} else {
game.has_won(player1)
}
EDIT2:
Please change the 0 index'd counting for the user, no human starts counting at 0
ty
Last edited by esa (2016-01-13 20:16:55)
Offline
John, you could save a lot of code by making your tic-tac-toe board as a bitflag representation. Just about all of game.cpp, for example, could be replaced with the following:
// bitflag representations of "wins": 3 vertical, 3 horizontal, 2 diagonal
int wins[] = { 0x01C0, 0x0038, 0x0007, 0x0124, 0x0092, 0x0049, 0x0111, 0x0054 };
// bitflag board representation for X pieces and O pieces:
int X;
int O;
int make_move(int input, int *player) {
if (input < 0 || input > 8) return -1;
if ( X & (1<<input) || Y & (1<<input) ) {
std::count << "\n\n... OVERLAP DETECTED...\n\n";
return -2;
}
*player |= (1<<input);
if (X | O == 0x01FF) isStalemate = true;
}
bool is_victory(int *player) {
int i;
for (i = 0; i < sizeof(wins) / sizeof(wins[0]); ++i)
if (*player & wins[i] == wins[i]) return true;
}
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for the replies guys! I had stopped working on this for a bit to finish up exams and stuff, but I plan on working on it again now.
Bitflags. That sounds interesting. I have a lot to learn as far as coding goes. That's for sure. Though that stuff looks really cool!
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline