-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateBoard.cpp
More file actions
120 lines (96 loc) · 1.92 KB
/
generateBoard.cpp
File metadata and controls
120 lines (96 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
Author : Asim Krishna Prasad
Aim :
1> Generate the current board matrix using current player matrix and
previous board matrix
*/
using namespace std;
#include <bits/stdc++.h>
#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)
#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)
#define ss(s) scanf("%s", s)
#define sc(c) scanf("%c", &c)
#define sd(f) scanf("%lf", &f)
#define pi(n) printf("%d\n", n)
#define pll(l) printf("%lld\n", l)
#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pd(f) printf("%lf\n", f)
#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")
#define mem(a,i) memset(a,i,sizeof(a))
#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define mclr(strn) strn.clear()
#define ignr cin.ignore()
#define PB push_back
#define SZ size
#define MP make_pair
#define fi first
#define sec second
const int LIMIT = 8;
vector<string> playerMatrix, prevBoard;
char pieceLifted;
int main()
{
int i, j, l;
fl(i,0,LIMIT)
{
string temp;
cin>>temp;
playerMatrix.PB(temp);
}
//freopen("prevBoard.txt", "r", stdin);
fl(i,0,LIMIT)
{
string temp;
cin>>temp;
prevBoard.PB(temp);
}
bool doBreak = 0;
fl(i,0,LIMIT)
{
fl(j,0,LIMIT)
{
if( playerMatrix[i][j] == '.' && prevBoard[i][j] != '.' && islower(prevBoard[i][j]))
{
pieceLifted = prevBoard[i][j];
//cout<<pieceLifted<<" "<<i<<" "<<j; nline;
prevBoard[i][j] = '.';
doBreak = 1;
break;
}
}
if(doBreak)
break;
}
doBreak = 0;
fl(i,0,LIMIT)
{
fl(j,0,LIMIT)
{
if( playerMatrix[i][j] == 'B' && (prevBoard[i][j] == '.' || isupper(prevBoard[i][j]) ) )
{
prevBoard[i][j] = pieceLifted;
doBreak = 1;
break;
}
}
if(doBreak)
break;
}
freopen("tempFile.txt", "w", stdout);
fl(i,0,LIMIT)
{
fl(j,0,LIMIT)
{
cout<<prevBoard[i][j];
}
nline;
}
return 0;
}