You are not logged in.

#1 2015-12-30 22:34:54

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

My console_games github repository

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 big_smile. 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

#2 2016-01-06 18:14:55

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: My console_games github repository

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

#3 2016-01-07 00:20:02

theGunslinger
Member
Registered: 2011-05-20
Posts: 300

Re: My console_games github repository

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

#4 2016-01-07 11:05:21

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: My console_games github repository

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. smile


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

#5 2016-01-13 20:04:34

esa
Member
Registered: 2011-12-29
Posts: 143
Website

Re: My console_games github repository

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 big_smile

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 wink
ty

Last edited by esa (2016-01-13 20:16:55)


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

#6 2016-01-13 20:36:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: My console_games github repository

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

#7 2016-01-17 23:17:41

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: My console_games github repository

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! big_smile


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

Board footer

Powered by FluxBB