Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Need Help with error

 
Post new topic   Reply to topic Printable version
 View previous topic  SCORE Keeping BOT Post :: Post local time?  View next topic  
Author Message
Underlord
Guest


Offline

PostPosted: Fri Feb 28, 2003 7:50 pm    Post subject: Need Help with error Reply to topic Reply with quote

Using a slightly modified version of Catid's elim dll for rank/perm stat writing to rank.dat

The error is that after awhile the rank.dat becomes corrupted and is just full of garbage data. ie /!rank <player> returns stuff like asdlfkjasldfj afds and random data from my memory, nothing involving player names/data.

I think it has to do with some pilots somehow incorrectly getting inputted into the rankings, b/c there becomes slots in ranks with blank data. The blank slots grow and eventually the entire file is corrupted. Other than the blank slots the bot runs fine until it closes... after the file is corrupted, then it can't reload b/c the file is messed. So it probably has something to do with how the LogPlayerGame(p); transition to rankings.ResortPlayers();, but i dunno whats wrong. The data file isn't immediately messed up after writing, but after awhile it does (from minutes to hours).

The likely places for the error are rank.cpp or spawn.cpp (void botInfo::Kill(Player *p, Player *k)) Maybe I need to do LogPlayerGame(p); at a different time, or maybe i need to do prank->updated = true; at a different time, or maybe rankings.entries_changed = true; rankings.ResortPlayers(); at a different time.

I've tried for hours to find the bug but can't, any help would be GREATLY appreciated.

http://www.dueling.net/bots/duel
spawn.cpp and rank.cpp, rank.h

heres the void botInfo::Kill(Player *p, Player *k); function where the error probably is:

Code: Show/Hide
void botInfo::Kill(Player *p, Player *k)
{
// cycle boxes searching for killer's box
for (int box = 1; box <= MAX_BOXES; box++)
if ((BoxPilot[box][0]) && (BoxPilot[box][1]))
if ((k->name == BoxPilot[box][0]->name) || (k->name == BoxPilot[box][1]->name))
{
// Update rank stats
PlayerRank *prank = rankings.FindRank(p->name);
PlayerRank *krank = rankings.FindRank(k->name);

LogPlayerGame(p);
LogPlayerGame(k);

if (prank)
{
prank->updated = true;
prank->data.deaths++;
}

if (krank)
{
krank->updated = true;
krank->data.kills++;
}

if ((prank) && (krank))
{
double kRold = krank->data.rating;
double kdiff = prank->data.rating - kRold;
double kwe = kdiff/400;
kwe = 1/(pow(10,kwe) + 1);
int kRnew = kRold + (30*(1-kwe));

krank->data.rating = kRnew;
krank->updated = true;

double pRold = prank->data.rating;
double pdiff = krank->data.rating - pRold;
double pwe = pdiff/400;
pwe = 1/(pow(10,pwe) + 1);
int pRnew = pRold + (30*(0-pwe));

prank->data.rating = pRnew;
prank->updated = true;
}

rankings.entries_changed = true;
rankings.ResortPlayers();

// killer gets full charge
sendPrivate(k, "*prize #13");

// warp killer to corner
String w = "*warpto ";
w += BoxCoordX3[box];
w += " ";
w += BoxCoordY3[box];
sendPrivate(k,w);

int kkrank=rankings.ranks.total + 1, pprank=rankings.ranks.total + 2, kkrating=1500;
int pprating=1500, kkkill=1, ppkill=0, kkdeath=0, ppdeath=1;

if (prank)
{
pprank = prank->data.rank;
pprating = prank->data.rating;
ppkill = prank->data.kills;
ppdeath = prank->data.deaths;
}

if (krank)
{
kkrank = krank->data.rank;
kkrating = krank->data.rating;
kkkill = krank->data.kills;
kkdeath = krank->data.deaths;
}

// increment winning streak for killer or set winner as killer with streak 1
if (winner[box])
if (k->name == winner[box]->name)
wincount[box]++;
else
{
winner[box] = k;
wincount[box] = 1;
}
else
{
winner[box] = k;
wincount[box] = 1;
}

// display killer/killed stats
char str[256];

/*
aaaagh-BAD-NEWS kb Palace (energy 169) (won 2 in a row)
(Palace Dmg Dealt: Total 5000, Bomb 1300, Bullet 0400) (Rank 1, Rating 1500, K/D 14-3)
(aaaagh-BAD-NEWS Dmg Dealt: Total 4030, Bomb 2040, Bullet 1000) (Rank 2, Rating 1750, K/D 51-6)
*/

sprintf(str, "*arena %s kb %s (energy %d) (won %d in a row)", p->name, k->name, k->energy, wincount[box]);
sendPublic(str);

sprintf(str, "*arena (%-20s Dmg Dealt: Total %0004d, Bomb %0004d, Bullet %0004d) (Rank %d, Rating %d, K/D %d-%d)",
p->name, get_tag(p,DMG_TOTAL_DEALT), get_tag(p,DMG_BOMB_DEALT), get_tag(p,DMG_BULLET_DEALT),
pprank, pprating, ppkill, ppdeath);
sendPublic(str);

sprintf(str, "*arena (%-20s Dmg Dealt: Total %0004d, Bomb %0004d, Bullet %0004d) (Rank %d, Rating %d, K/D %d-%d)",
k->name, get_tag(k,DMG_TOTAL_DEALT), get_tag(k,DMG_BOMB_DEALT), get_tag(k,DMG_BULLET_DEALT),
kkrank, kkrating, kkkill, kkdeath);
sendPublic(str);


// reset damage stats
set_tag(p, DMG_BULLET_DEALT, 0);
set_tag(p, DMG_BOMB_DEALT, 0);
set_tag(p, DMG_TOTAL_DEALT, 0);

set_tag(k, DMG_BULLET_DEALT, 0);
set_tag(k, DMG_BOMB_DEALT, 0);
set_tag(k, DMG_TOTAL_DEALT, 0);

// if theres a pilot next in line spec killed and put next pilot in
if (nextcount[box] > 0)
{
// spec killed
sendPrivate(p,"*spec");
sendPrivate(p,"*spec");

sendPrivate(next[box][0],"*setship 1");

String u = "*warpto ";
u += BoxCoordX2[box];
u += " ";
u += BoxCoordY2[box];
sendPrivate(next[box][0],u);

// incoming pilot gets killed's box slot
if (p->name == BoxPilot[box][0]->name)
BoxPilot[box][0] = next[box][0];

else if (p->name == BoxPilot[box][1]->name)
BoxPilot[box][1] = next[box][0];

// move up the next line
MoveUp(0,box);
}
break;
}
}
Back to top
VampZ
Guest


Offline

PostPosted: Sat Mar 01, 2003 2:21 am    Post subject: Reply to topic Reply with quote

where's the filing code?
Back to top
Underlord
Guest


Offline

PostPosted: Sat Mar 01, 2003 12:35 pm    Post subject: rank.cpp Reply to topic Reply with quote

rank.cpp
void ElimRanks::SaveRanks(const char *name)

some other important functions:
void ElimRanks::ResortPlayers()
PlayerRank *ElimRanks::FindRank(char *player_name)

spawn.cpp:
void botInfo::LogPlayerGame(Player *p)
Back to top
VampZ
Guest


Offline

PostPosted: Sat Mar 01, 2003 6:27 pm    Post subject: Reply to topic Reply with quote

where's the actual code?
Back to top
Underlord
Guest


Offline

PostPosted: Sat Mar 01, 2003 8:10 pm    Post subject: http://www.dueling.net/bots/duel Reply to topic Reply with quote

http://www.dueling.net/bots/duel
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 54 page(s) served in previous 5 minutes.

phpBB Created this page in 0.482714 seconds : 29 queries executed (95.3%): GZIP compression disabled