# I want to know the algorithm to write this game

• ### Question

• Hi!

I'm student.

Using windows application.

I'm developing a game based on the Battle of Waterloo, which was fought between the French and the English forces. In the game, the French and the English soldiers have to place bombs in the battlefield.

Rules of the Battle of Waterloo:

+ There are two players in the game, one representing the French forces and the other representing the English forces. The battlefield consists of nine squares, as shown in the following the English forces. The battlefield consists of nine squares.

+ The French and the English soldiers take turns in planting a bomb in any of the vacant squares. This process continues until:

• Either of the forces is able to  place three bombs in straight line-vertically, horizontally, or diagonally.
• Bombs have been placed in all the nine squares.

Design Specitications

The Battle of Waterloo should be designed to meet the following specifications:

• It is a single player game. The player will play the game against the computer.
• When the game starts, the player will be asked to enter his or her name. In addition, the player will be asked to specify whether he or she wants to place the first bomb in the battlefield.
• The battlefield should be represented by a large square that is made up of nine small squares.
• the player should interact with the game by using a mouse.
• The player will place a bomb in a square by clicking on that square.
• A bomb placed by the player will be displayed as a cross symbol (X) in the square.
• A bomb placed by the computer will be displayed as a circle (O) in the square.
• If the player is able to place three cross symbols in a straight line, the player wins the game.
• If the computer is able to place three circle in a straight line, the computer wins the game.
• If neither the player  nor the computer is able to place three bombs in a straight line and all the squares are filled, it is a tie.
• when the game gets over, the player should be given the options to start a new game.

• Moved by Monday, March 29, 2010 10:04 AM (From:Visual C# General)
Tuesday, March 23, 2010 10:49 AM

• Hey,

That's the wrong question..We can help you, but not do it for you.

Get your hands dirty and start working, then when you find a problem you can ask for help.

Doens't seem so complicated, its a lot similar to tic tac toe.

Hope this helps: http://www.codeproject.com/KB/cs/tictactoewin32.aspx

Best Regards, Diogo Pinheiro
• Proposed as answer by Wednesday, March 24, 2010 10:19 AM
• Proposed as answer by Wednesday, March 24, 2010 10:19 AM
• Unproposed as answer by Thursday, March 25, 2010 5:29 AM
• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Tuesday, March 23, 2010 12:52 PM
• I agree with Diogo.  Some advice.

There is a difference between an algorithm and an implementation.  The same algorithm could be implemented on a variety of hardware and software platforms.

You would be best to follow that principle as you design your application.  This means separating game logic from display logic.  Doing so will make your code easier to write, and simpler to test and debug.  It also means writing slightly more code, but it is worth the effort.

EDIT:

I also suggest that you write your code for your algorithm to imitate the real world, as if you had an actual game board with pieces in front of you.  Your algorithm needs to model that "Board".  This could be an array of "Tiles".  These "Tiles" would need to be able to be empty, or accept just one "GamePiece" of object.  Your "GamePiece" objects come in two types.  Board games follow a set of "Rules" that allow or disallow modifications to a "GamePiece" sitting on the "Board".

In the real world, modifications to the game board are made by your hand based upon a rule book.  Before the actual modification is made, the proposed change is validated or denied by the rule book.  When a change is validated, only then is the actual change made to the game board.

The game board needs to report any changes that are made to it, which means fire an event.  So that implementations of the game can create a visual or textual representation of game play.  I would put the algorithm in one assembly, and the implementation in another.  It would might even be good to create a Console Application that printed out instructions of where pieces should be moved on an actual game board for testing your algorithm.  Later, the algorithm could be implemented on a GUI interface.

If all of this sounds way to complicated for such a simple game, it probably is.  But, the point of the exercise is to application design.  Good designs may require more code to create.  But they are faster write and far, far easier to Debug.

Hope this helps.

Rudy  =8^D

Mark the best replies as answers. "Fooling computers since 1971."
• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Tuesday, March 23, 2010 1:43 PM
• Hi Aishiteru,

I think it is better to ask such kinds of questions in the XNA forum:
http://forums.xna.com/forums/45.aspx

李一坨

• Proposed as answer by Thursday, March 25, 2010 9:28 AM
• Unproposed as answer by Sunday, March 28, 2010 3:38 AM
• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Tuesday, March 23, 2010 1:52 PM
• Hello, Aishiteru

This forum mainly talked about C# programming(C# language features and so on), so your question is more algorithm specific, so please follow 李一坨's advice, post your question in XNA forum, that forum have Game Algorithms.

Thanks

Chao

• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Monday, March 29, 2010 10:01 AM

### All replies

• Hey,

That's the wrong question..We can help you, but not do it for you.

Get your hands dirty and start working, then when you find a problem you can ask for help.

Doens't seem so complicated, its a lot similar to tic tac toe.

Hope this helps: http://www.codeproject.com/KB/cs/tictactoewin32.aspx

Best Regards, Diogo Pinheiro
• Proposed as answer by Wednesday, March 24, 2010 10:19 AM
• Proposed as answer by Wednesday, March 24, 2010 10:19 AM
• Unproposed as answer by Thursday, March 25, 2010 5:29 AM
• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Tuesday, March 23, 2010 12:52 PM
• I agree with Diogo.  Some advice.

There is a difference between an algorithm and an implementation.  The same algorithm could be implemented on a variety of hardware and software platforms.

You would be best to follow that principle as you design your application.  This means separating game logic from display logic.  Doing so will make your code easier to write, and simpler to test and debug.  It also means writing slightly more code, but it is worth the effort.

EDIT:

I also suggest that you write your code for your algorithm to imitate the real world, as if you had an actual game board with pieces in front of you.  Your algorithm needs to model that "Board".  This could be an array of "Tiles".  These "Tiles" would need to be able to be empty, or accept just one "GamePiece" of object.  Your "GamePiece" objects come in two types.  Board games follow a set of "Rules" that allow or disallow modifications to a "GamePiece" sitting on the "Board".

In the real world, modifications to the game board are made by your hand based upon a rule book.  Before the actual modification is made, the proposed change is validated or denied by the rule book.  When a change is validated, only then is the actual change made to the game board.

The game board needs to report any changes that are made to it, which means fire an event.  So that implementations of the game can create a visual or textual representation of game play.  I would put the algorithm in one assembly, and the implementation in another.  It would might even be good to create a Console Application that printed out instructions of where pieces should be moved on an actual game board for testing your algorithm.  Later, the algorithm could be implemented on a GUI interface.

If all of this sounds way to complicated for such a simple game, it probably is.  But, the point of the exercise is to application design.  Good designs may require more code to create.  But they are faster write and far, far easier to Debug.

Hope this helps.

Rudy  =8^D

Mark the best replies as answers. "Fooling computers since 1971."
• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Tuesday, March 23, 2010 1:43 PM
• Hi Aishiteru,

I think it is better to ask such kinds of questions in the XNA forum:
http://forums.xna.com/forums/45.aspx

李一坨

• Proposed as answer by Thursday, March 25, 2010 9:28 AM
• Unproposed as answer by Sunday, March 28, 2010 3:38 AM
• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Tuesday, March 23, 2010 1:52 PM
• Hello, Aishiteru

This forum mainly talked about C# programming(C# language features and so on), so your question is more algorithm specific, so please follow 李一坨's advice, post your question in XNA forum, that forum have Game Algorithms.

Thanks

Chao

• Marked as answer by Tuesday, April 13, 2010 9:22 AM
Monday, March 29, 2010 10:01 AM