my game isnt working...see? this is the code. it prints a board like this:
10 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
9 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
8 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
7 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
6 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
5 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
4 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
3 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
2 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
1 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
1 2 3 4 5 6 7 8 9 10
anyways i wanted a "smart" opponent (the game would be like chess, or fire emblem, if you've played it) so i made a thing that would alter the enimies position, if the player got too close. the problem is the eniemy, keeps moving to these coordinates, ignoring the player: 5,5 (designated to start here) 4,4 4,3 3,2 2,1. i dont know why its doing this, but heres the code:
(yes i chould loop some stuff, and take out the variables...)
(the "enemy" is in bold)
#include <iostream>
using namespace std;
int main()
{
float a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, z;
float A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
float aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as;
float at, au, av, aw, ax, ay, az, ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl;
float bm, bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz, ca, cb, cc, cd, ce;
float cf, cg, ch, ci, cj, ck, cl, cm, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx;
float cy, cz, da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm, dn, dp, dq, dr;
float ds, dt, du, dv, dw, dx, dy, dz, ea, eb, ec, ed, ee, ef, eg, eh, ei, ej, ek;
float el, em, en, eo, ep, eq, er, es, et, eu, ev, ew, ex, ey, ez, fa, fb, fc, fd;
float fe, ff, fg, fh, fi, fj, fk, fl, fm, fn, fo, fp, fq, fr, fs, ft, fu, fv, fw;
float fx, fy, fz, ga, gb, gc, gd, ge, gf, gg, gh, gi, gj, gk, gl, gm, gn, go, gp;
float gq, gr, gs, gt, gu, gv, gw, gx, gy, gz, ha, hb, hc, hd, he, hf, hg, hh, hi;
float hj, hk, hl, hm, hn, ho, hp, hq, hr, hs, ht, hu, hv, hw, hx, hy, hz, ia, ib;
float ic, id, ie, ig, ih, ii, ij, ik, il, im, in, io, ip, iq, ir, is, it, iu, iv;
float iw, ix, iy, iz, ja, jb, jc, jd, je, jf, jg, jh, ji, jj, jk, jl, jm, jn, jo;
float jp, jq, jr, js, jt, jw, jx, jy, jz, ka, kb, kc, kd, ke, kf, kg, kh, ki, kj;
float kk, kl, km, kn, ko, kp, kq, kr, ks, kt, ku, kw, kx, ky, kz;
int x, y, world[10][10], sndx, sndy, zx, zy, aify, aifx;
aifx=5;
aify=5;
d=0;
cout<<"please note the world is a 10 by 10, empty grid\n";
cout<<" _____________________ \n";
cout<<" \\ Z MAP UV TH3 WUR1D/ \n";
cout<<" ____\\<!!!TH3 WUR1D!!!>/____ \n";
cout<<" \\ /-------------\\ / \n";
cout<<" /____/ \\____\\ \n";
cout<<"\n";
cout<<"10 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"9 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"8 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"7 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"6 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"5 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"4 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"3 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"2 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<"1 [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]\n";
cout<<" 1 2 3 4 5 6 7 8 9 10\n";
cout<<"at (1,1) is the first portal\n";
cin>> x >> y;
do {
world[0][0]=0;
world[0][1]=0;
world[0][2]=0;
world[0][3]=0;
world[0][4]=0;
world[0][5]=0;
world[0][6]=0;
world[0][7]=0;
world[0][8]=0;
world[0][9]=0;
world[1][9]=0;
world[1][0]=0;
world[1][1]=0;
world[1][2]=0;
world[1][3]=0;
world[1][4]=0;
world[1][5]=0;
world[1][6]=0;
world[1][7]=0;
world[1][8]=0;
world[1][9]=0;
world[2][0]=0;
world[2][1]=0;
world[2][2]=0;
world[2][3]=0;
world[2][4]=0;
world[2][5]=0;
world[2][6]=0;
world[2][7]=0;
world[2][8]=0;
world[2][9]=0;
world[3][0]=0;
world[3][1]=0;
world[3][2]=0;
world[3][3]=0;
world[3][4]=0;
world[3][5]=0;
world[3][6]=0;
world[3][7]=0;
world[3][8]=0;
world[3][9]=0;
world[4][0]=0;
world[4][1]=0;
world[4][2]=0;
world[4][3]=0;
world[4][4]=0;
world[4][5]=0;
world[4][6]=0;
world[4][7]=0;
world[4][8]=0;
world[4][9]=0;
world[5][0]=0;
world[5][1]=0;
world[5][2]=0;
world[5][3]=0;
world[5][4]=0;
world[5][5]=0;
world[5][6]=0;
world[5][7]=0;
world[5][8]=0;
world[5][9]=0;
world[6][0]=0;
world[6][1]=0;
world[6][2]=0;
world[6][3]=0;
world[6][4]=0;
world[6][5]=0;
world[6][6]=0;
world[6][7]=0;
world[6][8]=0;
world[6][9]=0;
world[7][0]=0;
world[7][1]=0;
world[7][2]=0;
world[7][3]=0;
world[7][4]=0;
world[7][5]=0;
world[7][6]=0;
world[7][7]=0;
world[7][8]=0;
world[7][9]=0;
world[8][0]=0;
world[8][1]=0;
world[8][2]=0;
world[8][3]=0;
world[8][4]=0;
world[8][5]=0;
world[8][6]=0;
world[8][7]=0;
world[8][8]=0;
world[8][9]=0;
world[9][0]=0;
world[9][1]=0;
world[9][2]=0;
world[9][3]=0;
world[9][4]=0;
world[9][5]=0;
world[9][6]=0;
world[9][7]=0;
world[9][8]=0;
world[9][9]=0;
aify=aify-1;
aifx=aifx-1;
world[aifx][aify]=2; //cout enemy, on board
x = x-1;//'cause of the "zeroeth"element
y = y-1;
world[x][y] = 1;//couts player on board
cout<<"\n";
cout<<"\n";
cout<<"10 ";
//couts the board, according to the values of world[][]==
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][9] == 1)
cout<<"[#]";
if(world[x][9]==2)
cout<<"[$]";
else if (world[x][9] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"9 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][8] == 1)
cout<<"[#]";
if(world[x][8]==2)
cout<<"[$]";
else if (world[x][8] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"8 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][7] == 1)
cout<<"[#]";
if(world[x][7]==2)
cout<<"[$]";
else if (world[x][7] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"7 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][6] == 1)
cout<<"[#]";
if(world[x][6]==2)
cout<<"[$]";
else if (world[x][6] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"6 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][5] == 1)
cout<<"[#]";
if(world[x][5]==2)
cout<<"[$]";
else if (world[x][5] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"5 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][4] == 1)
cout<<"[#]";
if(world[x][4]==2)
cout<<"[$]";
else if (world[x][4] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"4 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][3] == 1)
cout<<"[#]";
if(world[x][3]==2)
cout<<"[$]";
else if (world[x][3] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"3 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][2] == 1)
cout<<"[#]";
if(world[x][2]==2)
cout<<"[$]";
else if (world[x][2] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"2 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][1] == 1)
cout<<"[#]";
if(world[x][1]==2)
cout<<"[$]";
else if (world[x][1] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<"1 ";
for ( x = 0 ; x < 10 ; x++ ){
if (world[x][0] == 1)
cout<<"[#]";
if(world[x][0]==2)
cout<<"[$]";
else if (world[x][0] == 0)
cout<<"[ ]";
}
cout<<"\n";
cout<<" 1 2 3 4 5 6 7 8 9 10\n";
cout<<"\n";
do{
cin>> x >> y;
}
while(x>10 || y>10||(x>10 && y>10));
if(world[aifx][aify]=2){
if(world[aifx+1][aify]==1){
aifx=aifx+1;
}
if(world[aifx+2][aify]==1){
aifx =aifx +1;
}
if(world[aifx-1][aify]==1){
aifx =aifx -1;
}
if(world[aifx-2][aify]==1){
aifx =aifx -1;
}
if(world[aifx][aify+1]==1){
aify =aify +1;
}
if(world[aifx][aify+2]==1){
aify =aify +1;
}
if(world[aifx][aify-2]==1){
aify =aify -1;
}
if(world[aifx][aify-1]==1){
aify =aify -1;
}
if(world[aifx+1][aify+1]==1){
aifx =aifx +1;
}
if(world[aifx+1][aify-1]==1){
aify =aify -1;
}
if(world[aifx-1][aify-1]==1){
aify =aify-1;
}
if(world[aifx-1][aify+1]==1){
aifx =aifx -1;
}
}
}
while ( x <= 10 && y<=10);//so x/y stays on board
cin.get();
}