Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- //Variablen
- string posA = "", posB = "";
- unsigned int pos1 = 0, pos2 = 0, posZahlA = 0, posZahlB = 0;
- //Spielfeld-
- const int rows = 9;
- const int cols = 9;
- vector< vector<string> > spielfeld(rows, vector<string> (cols));
- //-linien
- for(unsigned int i=0; i < rows; ++i) {
- for(unsigned int j=0; j < cols; ++j) {
- spielfeld[i] [j] = " ___________ ";
- }
- }
- //Spielfiguren-
- const string wB = " ___wBauer__ ";
- const string sB = " ___sBauer__ ";
- const string wL = " __wLaeufer_ ";
- const string sL = " __sLaeufer_ ";
- const string wS = " _wSpringer_ ";
- const string sS = " _sSpringer_ ";
- const string wT = " ___wTurm___ ";
- const string sT = " ___sTurm___ ";
- const string wD = " ___wDame___ ";
- const string sD = " ___sDame___ ";
- const string wK = " __wKoenig__ ";
- const string sK = " __sKoenig__ ";
- //-aufstellung (schwarz)
- spielfeld[0] [1] = sT;
- spielfeld[0] [2] = sS;
- spielfeld[0] [3] = sL;
- spielfeld[0] [4] = sD;
- spielfeld[0] [5] = sK;
- spielfeld[0] [6] = sL;
- spielfeld[0] [7] = sS;
- spielfeld[0] [8] = sT;
- spielfeld[1] [1] = sB;
- spielfeld[1] [2] = sB;
- spielfeld[1] [3] = sB;
- spielfeld[1] [4] = sB;
- spielfeld[1] [5] = sB;
- spielfeld[1] [6] = sB;
- spielfeld[1] [7] = sB;
- spielfeld[1] [8] = sB;
- //-aufstellung (weiß)
- spielfeld[7] [1] = wT;
- spielfeld[7] [2] = wS;
- spielfeld[7] [3] = wL;
- spielfeld[7] [4] = wD;
- spielfeld[7] [5] = wK;
- spielfeld[7] [6] = wL;
- spielfeld[7] [7] = wS;
- spielfeld[7] [8] = wT;
- spielfeld[6] [1] = wB;
- spielfeld[6] [2] = wB;
- spielfeld[6] [3] = wB;
- spielfeld[6] [4] = wB;
- spielfeld[6] [5] = wB;
- spielfeld[6] [6] = wB;
- spielfeld[6] [7] = wB;
- spielfeld[6] [8] = wB;
- //Spielfeldbeschriftung & -formatierung
- spielfeld[0] [0] = "8";
- spielfeld[1] [0] = "7";
- spielfeld[2] [0] = "6";
- spielfeld[3] [0] = "5";
- spielfeld[4] [0] = "4";
- spielfeld[5] [0] = "3";
- spielfeld[6] [0] = "2";
- spielfeld[7] [0] = "1";
- spielfeld[8] [0] = "";
- spielfeld[8] [0] = " ";
- spielfeld[8] [1] = " _____a_____ ";
- spielfeld[8] [2] = " _____b_____ ";
- spielfeld[8] [3] = " _____c_____ ";
- spielfeld[8] [4] = " _____d_____ ";
- spielfeld[8] [5] = " _____e_____ ";
- spielfeld[8] [6] = " _____f_____ ";
- spielfeld[8] [7] = " _____g_____ ";
- spielfeld[8] [8] = " _____h_____ ";
- //Benutzereingabe Spielzüge
- while (posA != "exit") {
- //Figur geschlagen?
- //if()
- for(unsigned int i=0; i < rows; ++i) {
- if(i >= (rows-1)) {
- cout << endl;
- }
- for(unsigned int j=0; j < cols; ++j) {
- cout << spielfeld[i] [j];
- if(j>= (cols-1)) {
- cout << "\n" << endl;
- }
- }
- }
- //Eingabe
- cout << "Bitte geben Sie einen Spielzug ein (z.B.: Von: a2 Zu: a3):" << endl;
- cout << "Start Buchstabe: ";
- cin >> posA;
- //Umwandlung Buchstabe in Zahl: posA
- if(posA == "a") {posZahlA = 1;}
- else if (posA == "b") {posZahlA = 2;}
- else if (posA == "c") {posZahlA = 3;}
- else if (posA == "d") {posZahlA = 4;}
- else if (posA == "e") {posZahlA = 5;}
- else if (posA == "f") {posZahlA = 6;}
- else if (posA == "g") {posZahlA = 7;}
- else if (posA == "h") {posZahlA = 8;}
- else if (posA == "exit") {cout << "Spielende" << endl;}
- else {cout << "ungültige Eingabe!" << endl;}
- cout << "Start Zahl: ";
- cin >> pos1;
- //Umwandlung Buchstabe in Zahl: posB
- if(posB == "a") {posZahlB = 1;}
- else if (posB == "b") {posZahlB = 2;}
- else if (posB == "c") {posZahlB = 3;}
- else if (posB == "d") {posZahlB = 4;}
- else if (posB == "e") {posZahlB = 5;}
- else if (posB == "f") {posZahlB = 6;}
- else if (posB == "g") {posZahlB = 7;}
- else if (posB == "h") {posZahlB = 8;}
- else {cout << "ungültige Eingabe!" << endl;}
- cout << "Ziel Buchstabe: ";
- cin >> posB;
- //Umwandlung VektorZahl in FeldZahl: pos1
- if(pos1 == 1) {pos1 = 7;}
- else if (pos1 == 2) {pos1 = 6;}
- else if (pos1 == 3) {pos1 = 5;}
- else if (pos1 == 4) {pos1 = 4;}
- else if (pos1 == 5) {pos1 = 3;}
- else if (pos1 == 6) {pos1 = 2;}
- else if (pos1 == 7) {pos1 = 1;}
- else if (pos1 == 8) {pos1 = 0;}
- else {cout << "ungültige Eingabe!" << endl; continue;}
- cout << "Ziel Zahl: ";
- cin >> pos2;
- //Umwandlung VektorZahl in FeldZahl: pos2
- if(pos2 == 1) {pos2 = 7;}
- else if (pos2 == 2) {pos2 = 6;}
- else if (pos2 == 3) {pos2 = 5;}
- else if (pos2 == 4) {pos2 = 4;}
- else if (pos2 == 5) {pos2 = 3;}
- else if (pos2 == 6) {pos2 = 2;}
- else if (pos2 == 7) {pos2 = 1;}
- else if (pos2 == 8) {pos2 = 0;}
- else {cout << "ungültige Eingabe!" << endl;}
- //Spielzüge Änderung
- spielfeld[pos2] [posZahlB] = spielfeld[pos1] [posZahlA];
- spielfeld[pos1] [posZahlA] = " ___________ ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement