Basic Bot 0.3.3, now allows toggles while computing. bot can now process in parts, but it will desync for some reason, need to check this later. single-segment still works fine.

This commit is contained in:
qfox 2006-11-19 22:45:40 +00:00
parent bb77f84fe3
commit 84e4c81061
7 changed files with 580 additions and 209 deletions

View File

@ -1,4 +1,27 @@
This changelog only concerns the Basic Bot code.
Changelog 0.3.3:
19 november 2006
- Added - Command - "invalids" and "oks" return their values. Usefull for determining whether to move on, or perhaps to change a value depending on the number of invalids.
- Added - GUI - You can now set the number of frames to skip, as well as the number of ms to wait after a frame-update. This can help you to evaluate your bot more closely.
- Added - Code - Major update here... The bot can now process a game part by part. Parts are from their start up to where they are deemed Ok (or Invalid, but invalids are never saved as "best"). When they are Ok (or Invalid) the code checks if the Max Attempts condition is true. If so, it will load and play the best attempt and save at the end, then continue where it was with the next part. This way you can cover a game in parts.
- Change - Save - The code used to just load the default savestate no-matter-what. Now, when you press run, it loads the default save state. Immediately after he saves it to a "botstate" state. From there-on he loads from this state. When a part is done, he saves to this state as well. Will add a button later to load this specific state.
- Added - GUI - Another column to show the stats of the last part
- Change - Code - Upped the recording limit to 10.000 frames (needed it myself :)
- Added - Command - A variable (for bot) that holds the current scores: score tie1 tie2 tie3 tie4 tie5. Can be used to discard a current run if the score is already lower then the highest current score. Can be a serious time-saver when the number of frames is a condition
Known issues:
- There still seems to be a desync sometimes... only happens when you use the part-system. it doesnt desync a single run attempt.
- There is a nasty bug occuring between parts. Sort of like a desync, even though I'm not sure whether that's even possible. But it sometimes tends to save a run that should have been marked invalid.
- If the start of a new part makes the "invalid" return true immediately, the bot goes bananaz. You might as well stop it because it will only keep on doing the same thing.
- When pressing update, the GUI sometimes reverts some changes you made. Not sure why the behavious is like that when it happens, but I should investigate and change it.
Todo:
- Fix that nasty desync!
- Add a button that in/validates a current run immediately. This should prohibit runs that are obviously ok but don't meet all the requirements set by you yet.
- Add logging stuff
- Add code to run at the start of an attempt, to initialize variables.
Changelog 0.3.2:
16 september 2006

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
#ifndef _BASICBOT_H_
#define _BASICBOT_H_
#define BOT_MAXFRAMES 2048 // qfox: max number of frames to be computed per attempt...
#define BOT_MAXFRAMES 10000 // qfox: max number of frames to be computed per attempt...
#define BOT_STATEFILE "botstate" // the filename to save the current state to
void UpdateBasicBot();
void CreateBasicBot();
extern char *BasicBotDir;
@ -21,9 +22,13 @@
void InitCode();
void ResetStats();
void UpdateBestGUI();
static void PlayBest();
void UpdateLastGUI(int last[]);
void UpdateAvgGUI();
void UpdateFullGUI();
void UpdateCountersGUI();
void SetNewAttempt();
void UpdatePrevGUI(int best[]);
int BotFrameSkip();
int BotFramePause();
#endif // _BASICBOT_H_

View File

@ -346,7 +346,6 @@ void _updateMemWatch() {
#ifdef _USE_SHARED_MEMORY_
HANDLE mapGameMemBlock;
HANDLE mapRAM;
HANDLE mapBotInput;
uint32 *BotInput;
void win_AllocBuffers(uint8 **GameMemBlock, uint8 **RAM) {
@ -375,10 +374,11 @@ void win_AllocBuffers(uint8 **GameMemBlock, uint8 **RAM) {
SFCPU[6].v = *RAM;
//Bot input
// qfox: replaced 4096 by BOT_MAXFRAMES to make it possible to increase the number of frames
// the bot can compute in one single attempt.
mapBotInput = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0, BOT_MAXFRAMES*sizeof(int), "fceu.BotInput");
BotInput = (uint32 *) MapViewOfFile(mapBotInput, FILE_MAP_WRITE, 0, 0, 0);
// qfox: tossed mapping alltogether
//mapBotInput = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0, BOT_MAXFRAMES*sizeof(int), "fceu.BotInput");
//BotInput = (uint32 *) MapViewOfFile(mapBotInput, FILE_MAP_WRITE, 0, 0, 0);
// qfox: not working with a map anymore
BotInput = new uint32[BOT_MAXFRAMES];
BotInput[0] = 0;
}
@ -407,9 +407,8 @@ void win_FreeBuffers(uint8 *GameMemBlock, uint8 *RAM) {
GameMemBlock = NULL;
}
UnmapViewOfFile(mapBotInput);
CloseHandle(mapBotInput);
BotInput = NULL;
// qfox: not working with map anymore
delete BotInput;
}
#endif
@ -775,17 +774,32 @@ void _updateWindow() {
// } // end of !(old sound code) block
//}
// qfox 09/17/06: moved the skipcount outside because it was completely pointless
// in there.
/**
* Counts the number of frames that have not been displayed
* Used for the bot, to skip frames (and save time).
**/
int skipcount = 0;
/**
* Update the game and gamewindow with a new frame
**/
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
{
//mbg merge 7/19/06 - leaving this untouched but untested
//its probably not optimal
if(FCEU_BotMode()) {
//this counts the number of frames we've skipped blitting
static int skipcount = 0;
if(XBuf && (skipcount++ >= 64))
// qfox 09/17/06: for bot evaluation purposes, the number
// of frames to be skipped is set from the
// bot gui.
if(XBuf && (skipcount++ >= BotFrameSkip()))
{
skipcount = 0;
FCEUD_BlitScreen(XBuf);
// qfox 17/09/06: it can be wishfull for a coder to evaluate his bot.
// slowing it down can help here :) defaults at 0
if (BotFramePause() > 0) Sleep(BotFramePause());
}
UpdateFCEUWindow();
FCEUD_UpdateInput();

Binary file not shown.

View File

@ -81,12 +81,26 @@
#define GUI_BOT_TIE3_LAST 1073
#define GUI_BOT_TIE4_LAST 1074
#define GUI_BOT_TIE5_LAST 1075
#define GUI_BOT_ATTEMPT_LAST2 1076
#define GUI_BOT_ATTEMPT_LAST3 1077
#define GUI_BOT_SKIPS 1077
#define GUI_BOT_FRAMES_LAST 1078
#define GUI_BOT_FRAMES_BEST 1079
#define GUI_BOT_OKS 1080
#define GUI_BOT_ATTEMPT_PREV 1081
#define GUI_BOT_INVALIDS 1082
#define GUI_BOT_SCORE_PREV 1083
#define GUI_BOT_TIE1_PREV 1084
#define GUI_BOT_TIE2_PREV 1085
#define GUI_BOT_TIE3_PREV 1086
#define GUI_BOT_TIE4_PREV 1087
#define GUI_BOT_TIE5_PREV 1088
#define GUI_BOT_FRAMES_PREV 1089
#define GUI_BOT_PART_LAST 1090
#define GUI_BOT_PART_BEST 1091
#define GUI_BOT_PART_PREV 1092
#define GUI_BOT_LB_PREV 1093
#define GUI_BOT_TIE5_PREV3 1094
#define GUI_BOT_SLOW 1095
#define GUI_BOT_FRAMESKIP 1096
#define ID_DEBUG_DEBUGGER 40053
#define ID_DEBUG_PPUVIEWER 40054
#define ID_DEBUG_NAMETABLEVIEWER 40055
@ -103,7 +117,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40013
#define _APS_NEXT_CONTROL_VALUE 1077
#define _APS_NEXT_CONTROL_VALUE 1097
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -224,14 +224,14 @@ void FCEU_UpdateBot()
FCEUI_FrameAdvance();
break;
case 1:
FCEUI_LoadState(0);
FCEUI_LoadState(BOT_STATEFILE);
break;
default:
break;
}
//Bot input ends; let the world know we're done
if(BotPointer >= BotInput[0] || BotPointer >= 1023)
if(BotPointer >= BotInput[0] || BotPointer >= BOT_MAXFRAMES-1)
{
BotInput[0] = 0;
BotPointer = 0;