mardi 10 mars 2020

Domineering game c++ [closed]

I am making a domineering game on C++, I have created the board which the user can enter how many rows and columns they want, whether is a 4x4 or an 8x8 etc. Now I am trying to run a main loop:

by trying to have have the rows and columns numbers along the board edges to aid in entering moves. Check if the current player has any moves left, and announce the winner (i.e. the other player) if not. Ask the player what they want to do. They must be able to:  place a piece, by naming its top/left square (using row and column numbers). I also want to check if this move is legal (i.e. the square and its lower/right neighbour are both empty). quit (input “q” or “Q”), ending the game (I know how to do this but sometimes I there might be an error but I may be able to sort it out) save (input “s” or “S”) the current state of the game to a file (you need to query for the file name) (I know how to do the file open code but not sure on how it will look like when saving the game etc.) load (input “l” or “L”) a game state from a file

#include <Windows.h>

#include <iostream>
#include <vector>

using namespace std;
int main() {
    int vertical = 0;
    int horizontal = 0;
    int row = 0;
    int column = 0;

    // specify default value to fill the vector elements
    int mapSize = 8;
    cout << "Enter the size of board => ";
    cin >> mapSize;

    vector<vector<char>> board(mapSize, vector<char>(mapSize, 'e'));
    for(int i = 0; i < mapSize; i++) {
        for(int j = 0; j < mapSize; j++) {
            cout << board[i][j] << " ";
        }
        cout << endl;
    }
}

Aucun commentaire:

Enregistrer un commentaire