Jump to content

design tower of hanoi game with C++ using stack

ebdaa3sea
Go to solution Solved by Sneaky,

For the IDE I would recommend Visual Studio 2013 community edition, it has everything that you need. You don't need DirectX / OpenGL, if you want you can create it using just the console but I would recommend SFML, it is very easy to pick up and use. But from your post I get the opinion that you have no programming experience, you may want to start small and learn the basics without using any graphics libraries.

My problem


I want design tower of Hanoi game with C++ using stack


But i do not know how can i start and what IDES use


Question


1-Can i use windows form foe visual studio for create this game or no??


2-How can i move disk from column A& B& C and how can i do it ??


3- is necessary use OpenGL , Direct X or is not necessary??


4- what about insert pic for column and disk for moving between column as object ??


Link to comment
Share on other sites

Link to post
Share on other sites

Do you want to be able to play the game yourself or make an algorithm to play it?

 

Also, are you talking about std::stack? It's not really necessary, a vector (STL) would do just fine.

 

All IDEs will work.

 

Do you want graphics in your game? You could make it a console came. If you are indeed going for graphics, then I suggest SDL.

 

Also, do you have a set number of disks or based on difficulty, user-input,etc?

 

 

 

And how the algorithm would work (for the game logic):

You have 3 vectors, 1 for each rod. (or stacks, it would be the same thing. Make sure you use std::vector and not the standard array.Or use your stacks , doesn't matter. We'll be using push_back() anyway.

Or you could have a matrix.

 

You initialize the first vector with numbers going from 1 to n, where n is the number of disks.

 

Then, if you want to move an item from the first vector, to let's say the third vector, you store the top-most value in the vector in a temp. variable, delete that item from that vector(pop_back() ), then push_back that value into the vector you want to move it to.

 

Game won when you achieve a vector with the elements from 1 to n (in successive order), but it must be a vector different than the one which you initialized in the begining. 

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

For the IDE I would recommend Visual Studio 2013 community edition, it has everything that you need. You don't need DirectX / OpenGL, if you want you can create it using just the console but I would recommend SFML, it is very easy to pick up and use. But from your post I get the opinion that you have no programming experience, you may want to start small and learn the basics without using any graphics libraries.

Link to comment
Share on other sites

Link to post
Share on other sites

thank you for answer me 

 

do you have a set number of disks or based on difficulty, user-input,etc?

 

i want set number of disk 

 

Do you want graphics in your game? You could make it a console came. If you are indeed going for graphics, then I suggest SDL.

yes but i don`t know how i start  

in SDL can i move the desk ?? 

Link to comment
Share on other sites

Link to post
Share on other sites

Do you want to be able to play the game yourself or make an algorithm to play it?

 

Also, are you talking about std::stack? It's not really necessary, a vector (STL) would do just fine.

 

All IDEs will work.

 

Do you want graphics in your game? You could make it a console came. If you are indeed going for graphics, then I suggest SDL.

 

Also, do you have a set number of disks or based on difficulty, user-input,etc?

 

 

 

And how the algorithm would work (for the game logic):

You have 3 vectors, 1 for each rod. (or stacks, it would be the same thing. Make sure you use std::vector and not the standard array.Or use your stacks , doesn't matter. We'll be using push_back() anyway.

Or you could have a matrix.

 

You initialize the first vector with numbers going from 1 to n, where n is the number of disks.

 

Then, if you want to move an item from the first vector, to let's say the third vector, you store the top-most value in the vector in a temp. variable, delete that item from that vector(pop_back() ), then push_back that value into the vector you want to move it to.

 

Game won when you achieve a vector with the elements from 1 to n (in successive order), but it must be a vector different than the one which you initialized in the begining. 

thank you for answer me 

 

do you have a set number of disks or based on difficulty, user-input,etc?

 

i want set number of disk 

 

Do you want graphics in your game? You could make it a console came. If you are indeed going for graphics, then I suggest SDL.

yes but i don`t know how i start  

in SDL can i move the desk ?? 

Link to comment
Share on other sites

Link to post
Share on other sites

For the IDE I would recommend Visual Studio 2013 community edition, it has everything that you need. You don't need DirectX / OpenGL, if you want you can create it using just the console but I would recommend SFML, it is very easy to pick up and use. But from your post I get the opinion that you have no programming experience, you may want to start small and learn the basics without using any graphics libraries.

yes h have  Visual Studio 2013 community edition but i don`t know how can use for my game 

 

This is the first time programmed game but i want create graphic for my game even it is simple 

Link to comment
Share on other sites

Link to post
Share on other sites

yes h have  Visual Studio 2013 community edition but i don`t know how can use for my game 

 

This is the first time programmed game but i want create graphic for my game even it is simple 

Check out something called SFML, it's a very good graphics API that's very easy to learn and integrate into C++.

Link to comment
Share on other sites

Link to post
Share on other sites

Before you can start making games you need to have a good programming knowledge, and from the questions you asked it doesn't look like you have enough experience to make a game.

First of all pick up a good book: http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-listand learn at least the basics of C++.

Then you can start making games, there are lots of libraries that allows you to handle graphics, and input quite easily without the need to write directly in DirectX / OpenGL, like SFML (which is the one I use), SDL (this one is written in C, so is not object oriented so you may not like the syntax), Allegro (I've never used this, no idea if it's any good), or if you want to make your life easier use an engine, Cocos2d-x for example.

Link to comment
Share on other sites

Link to post
Share on other sites

Before you can start making games you need to have a good programming knowledge, and from the questions you asked it doesn't look like you have enough experience to make a game.

First of all pick up a good book: http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-listand learn at least the basics of C++.

Then you can start making games, there are lots of libraries that allows you to handle graphics, and input quite easily without the need to write directly in DirectX / OpenGL, like SFML (which is the one I use), SDL (this one is written in C, so is not object oriented so you may not like the syntax), Allegro (I've never used this, no idea if it's any good), or if you want to make your life easier use an engine, Cocos2d-x for example.

thank you for answer me :)

 

Note:

i have basic and some advance subject of c++ i `m study C++ before but this is first time programming game :) :) :) 

Link to comment
Share on other sites

Link to post
Share on other sites

Towers of Hanoi is a simple programming homework assignment, its used to build mastery of stack data structures. All you need to do is create 3 separate stacks and then check the final stack to see if the numbers you push onto the stack are in the correct order. using simple cin and cout you can display instructions and gather inputs from a player.

 

Build the game using command line in VS.

 

Here is a visual representation of towers of hanoi, each rod is a stack and each disk is an element in the stack.

TowersofHanoiSolution_700.gif

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×