예제 #1
0
/* process the latest information from ALE */
void JourneyEscapeSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0x92, 0x91, 0x90, &system);
    int reward = score - m_score;
    if (reward == 50000) reward = 0;  // HACK: ignoring starting cash
    m_reward = reward;
    m_score = score;

    // update terminal status
    int minutes = readRam(&system, 0x95);
    int seconds = readRam(&system, 0x96);
    m_terminal = minutes == 0 && seconds == 0;
}
/* process the latest information from ALE */
void MsPacmanSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0xF8, 0xF9, 0xFA, &system);
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0xFB) & 0xF;
    // MGB Did not work int black_screen_byte = readRam(&system, 0x94);
    int death_timer = readRam(&system, 0xA7);
    m_terminal = lives == 0 && death_timer == 0x53;
}
예제 #3
0
파일: gr909.c 프로젝트: aircross/ray
int capUsingRinging40Hz( void)  
{ 
	unsigned short sample10ms, sample1sec ;
#ifdef PCM_SLIC_FLOAT	
	double capValue, ratio;
	

	// It is necessary to lower VOC to allow the Ringing State Machine to proceed
	delay(200);
	writeRam(RINGOF	,	0);
	writeRam( RINGFRHI,0x3DF8);
	writeRam( RINGFRLO,0x5440);
	writeRam( RINGAMP,0x4D);
	writeRam( RINGPHAS,0x0);
	writeRam( RTCOUNT,0x190);
	writeRam( RTDCTH,0x7FFF);
	writeRam( RTPER,0x28);
	writeRam( RTACTH,0x7FFF);
	writeRam( RTDCDB,3);
	writeRam( RTACDB,3);
	writeReg( RINGCON,0X0);

	writeRam(DIAGACCO,0X10);
	writeRam(VOC,0x000); 
	writeRam(VCM,0);

	writeReg(LINEFEED,4);  // start ringing
	writeReg(DIAG,0Xcc) ; // High Preciscion current loop current
	delay(10); //wait milliseconds for it to take effect 
	sample10ms= readRam(DIAGAC);
	delay(1000);
	sample1sec= readRam(DIAGAC);
	ratio=0;
	ratio = 17/(((double)sample1sec) *.000003097 * 5.5);

	
	//capValue = (((float)sample1sec-(float)sample10ms)*4.69)/ (float)(1346);	
	capValue = (1.25e-6*sqrt((double)(640512102400.01-(ratio*ratio))))/(251.3274*sqrt((double)((ratio*ratio)-102400)));
	//see AN71 for equation details.

	printf("\n Cap = %f uF  %d, %f ",  (capValue*1000000)-.16, sample1sec,ratio);

	writeReg(LINEFEED,1);
	writeRam(VOC,0x000); 
	
	delay(100);
#endif
	return(0);
}
예제 #4
0
파일: Tutankham.cpp 프로젝트: gandalfvn/EOH
/* process the latest information from ALE */
void TutankhamSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0x9C, 0x9A, &system);
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0x9E);
    // byte 0x81 is set to 0x84 when the game is loaded, but not reset
    int some_byte = readRam(&system, 0x81);

    m_terminal = lives == 0 && some_byte != 0x84;
}
/* process the latest information from ALE */
void PooyanSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0x8A, 0x89, 0x88, &system);
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int lives_byte = readRam(&system, 0x96);
    int some_byte  = readRam(&system, 0x98);
    m_terminal = (lives_byte == 0x0 && some_byte == 0x05);

    m_lives = (lives_byte & 0x7) + 1;
}
예제 #6
0
파일: Venture.cpp 프로젝트: 10sun/DRL-AI
/* process the latest information from ALE */
void VentureSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0xC8, 0xC7, &system);
    score *= 100;
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0xC6);
    int audio_byte = readRam(&system, 0xCD);
    int death_byte = readRam(&system, 0xBF);
    m_terminal = (lives == 0 && audio_byte == 0xFF && death_byte & 0x80);
}
/* process the latest information from ALE */
void UpNDownSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0x82, 0x81, 0x80, &system);
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int lives_byte = readRam(&system, 0x86) & 0xF;
    int death_timer = readRam(&system, 0x94);
    m_terminal = death_timer > 0x40 && lives_byte == 0;

    m_lives = lives_byte + 1;
}
예제 #8
0
파일: gr909.c 프로젝트: aircross/ray
void tipRingCurrentOverVoltageRev( short currents[])  // 0 to 50 volts in 5 volt increments
{ 
	unsigned short vocValue =0 , i ;
//	doReset();
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);
	writeRam(VOC,TENVOLTINC);
	writeRam(VOCDELTA,0);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,5);  // Go to Active
	writeReg(DIAG,0XCC) ; // High Preciscion current loop current
	writeRam(DIAGDCCO,0X20);
	for ( vocValue = TENVOLTINC, i=0 ; i < 5; i++) 
	{

		delay(20);
		writeRam(VOC, vocValue); // Write out voltages starting with zero and going to 50 volts
		vocValue += TENVOLTINC;
		
		writeRam(DIAGDCCO,FLUSH);
		delay(100);
		writeRam(DIAGDCCO,LPFPOLE);
		delay(PROCESSING);
		currents[i] = readRam(DIAGDC);
		
	}
	printf("\n  TiptoRing =");
	for (i=0;i<5;i++) printf(" %d ",  currents[i]);
}
예제 #9
0
파일: gr909.c 프로젝트: aircross/ray
int LowREN( void)  
{
	unsigned short a[200], i ;
//	doReset();
//	initialize(); 
//	changeCID(0);

	writeRam(VOC,3*TENVOLTINC);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,1);  // Go to Active
	writeRam(DIAGDCCO,0X1fFF);


	delay(40);
	writeReg(LINEFEED,0);
	delay(100);
	for(i=0;i<200; i++)
	{
		delay (2);
		a[i] = readRam(VRING);
	}


	if  (((a[0]-a[4]) < 300)  && (a[4] >3410))
	{

		printf("\t\t\t\t\nREN between .175 and 1");
		return(-1);

	}

	printf("\t\t\t\t\nREN < .175");
	return(0);

}
예제 #10
0
파일: Asterix.cpp 프로젝트: gandalfvn/EOH
/* process the latest information from ALE */
void AsterixSettings::step(const System& system) {

    // update the reward
    reward_t score = getDecimalScore(0xE0, 0xDF, 0xDE, &system); 
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0xD3) & 0xF;
    int death_counter = readRam(&system, 0xC7);
    
    // we cannot wait for lives to be set to 0, because the agent has the
    // option of the restarting the game on the very last frame (when lives==1
    // and death_counter == 0x01) by holding 'fire'
    m_terminal = (death_counter == 0x01 && lives == 1);
}
예제 #11
0
파일: gr909.c 프로젝트: aircross/ray
void RENtest (  unsigned short *ren)
{  
	unsigned short max=0, i, readingILOOP;

//	doReset();
//	initialize(); 
//	changeCID(0);
	writeRam(VOC,0X1000);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,1);  // Go to Active
	
	delay (1000);
	writeRam(VOC, 0x800);

	delay(20);
	for (i=0;i<30	;i++)
	{
	
		readingILOOP =  0x7fff& readRam(ILOOP);
		max = (readingILOOP>max)?readingILOOP:max;

	}

	*ren = max /240;
	if (*ren >5)
		printf("\nRen >5");
	else if ((*ren) ==0)
		LowREN();
	else
		printf("\nRen = %i",*ren);
	delay (1000);

}
/* process the latest information from ALE */
void IceHockeySettings::step(const System& system) {

    // update the reward
	int my_score = BSPF_max(getDecimalScore(0x8A, &system), 0);
	int oppt_score = BSPF_max(getDecimalScore(0x8B, &system), 0);
    int score = my_score - oppt_score;
	int reward = BSPF_min(score - m_score, 1);
    m_reward = reward;
    m_score = score;

    // update terminal status
    int minutes = readRam(&system, 0x87);
    int seconds = readRam(&system, 0x86);
    // end of game when out of time
    m_terminal = minutes == 0 && seconds == 0;  
}
예제 #13
0
/* extracts a decimal value from 2 bytes */
int getDecimalScore(int lower_index, int higher_index, const System* system) {

    int score = 0;
    int lower_digits_val = readRam(system, lower_index);
    int lower_right_digit = lower_digits_val & 15;
    int lower_left_digit = (lower_digits_val - lower_right_digit) >> 4;
    score += ((10 * lower_left_digit) + lower_right_digit);
    if (higher_index < 0) {
        return score;
    }
    int higher_digits_val = readRam(system, higher_index);
    int higher_right_digit = higher_digits_val & 15;
    int higher_left_digit = (higher_digits_val - higher_right_digit) >> 4;
    score += ((1000 * higher_left_digit) + 100 * higher_right_digit);
    return score;
}
예제 #14
0
파일: gr909.c 프로젝트: aircross/ray
int capUsingRinging( void)  // 0 to 50 volts in 5 volt increments
{ 
	unsigned short sample10ms, sample1sec;
#ifdef PCM_SLIC_FLOAT	
	double ratio ;
	double capValue;

	
	// It is necessary to lower VOC to allow the Ringing State Machine to proceed
	delay(200);
	writeRam( RINGOF	,	0);
	writeRam( RINGFRHI,0x3F78);
	writeRam( RINGFRLO,0x6CE8);
	writeRam( RINGAMP,0x4D);
	writeRam( RINGPHAS,0x0);
	writeRam( RTCOUNT,0x190);
	writeRam( RTDCTH,0x7FFF);
	writeRam( RTPER,0x28);
	writeRam( RTACTH,0x7FFF);
	writeRam( RTDCDB,3);
	writeRam( RTACDB,3);
	writeReg( RINGCON,0X0);


	writeRam(DIAGACCO,0X10);//see AN71 and Si3220 datasheet for info on how to use diagnostic registers
	writeRam(VOC,0x000); 
	writeRam(VCM,0);
	writeReg(LINEFEED,4);  // start ringing
	writeReg(DIAG,0Xcc) ; // High Preciscion current loop current
	delay(10); //wait milliseconds for it to take effect 
	sample10ms= readRam(DIAGAC);
	delay(1000);
	sample1sec= readRam(DIAGAC);
	

	ratio = 17/(sample1sec *.000003097 * 2.5);//1.11072);
	capValue = (1.25e-6*sqrt((double)(640512102400.01-(ratio*ratio))))/(125.663706*sqrt((double)((ratio*ratio)-102400)));
	//see AN71 for equation details.
	printf("\n Cap = %f uF  %d, %f ",  (capValue*1000000)-.16, sample1sec,ratio);

	writeReg(LINEFEED,1);
	writeRam(VOC,0x000); 
	
	delay(100);
#endif
	return(0);
}
예제 #15
0
파일: gr909.c 프로젝트: aircross/ray
void RRG ( )  // 0 to 50 volts in 5 volt increments

{ 
#ifdef PCM_SLIC_FLOAT	
	double tipVoltage,ringVoltage, ringcurrent,rrgdiv, rrgImeth, rrgout, tipRingVoltage;
//	doReset();
//	changeCID(0);
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);

	writeRam(VOC,TENVOLTINC);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,5);  // Go to Active
//	while(1);
	writeRam(VOC,5*TENVOLTINC/3 ); // Write out voltages starting with zero and going to 50/3 ; this is the expected voltage on the high imp resistor
//	delay (100);
	writeReg(LINEFEED,7);
	writeRam(VOC,5*TENVOLTINC );
		delay(1000);// wait a long time for capassitance to settle
		ringVoltage = -1 *.00492 * (float) readRam(VRING);
		tipVoltage = -1 * .00492 * (float) readRam(VTIP);
		tipRingVoltage = tipVoltage-ringVoltage;
		rrgdiv = (ringVoltage*800)/((tipRingVoltage)-(2*ringVoltage)+3);
	writeRam(VOC,2 * TENVOLTINC); // step through voltage slowly to avoid ringing ringer
	writeReg(LINEFEED,3); // Activate reverse active (low resistance feed)
	writeRam(VOC,5 * TENVOLTINC);// step up other direction ( Foward active)
	delay (1000);
	ringcurrent = -1*(readRam(IRING)&0x7FFF) * .000003097;
	ringVoltage = -1*.00492 * (float) readRam(VRING);
	tipVoltage = -1 * .00492 * (float) readRam(VTIP);
	tipRingVoltage = tipVoltage-ringVoltage;
	rrgImeth =ringVoltage/(1000*ringcurrent-((ringVoltage-1.5)/402) - ((ringVoltage-tipVoltage)/800));
	if (rrgdiv<15 && rrgdiv>5){
		rrgout = rrgImeth;
	}
	else
	{
		rrgout = rrgdiv;
	}
	if (rrgout<0)
		rrgout =1000;

	printf("\nR R-G = %.0f ohms", rrgout*1000);
#endif	
}
예제 #16
0
/* extracts a decimal value from 3 bytes */
int getDecimalScore(int lower_index, int middle_index, int higher_index, const System* system) {

    int score = getDecimalScore(lower_index, middle_index, system);
    int higher_digits_val = readRam(system, higher_index);
    int higher_right_digit = higher_digits_val & 15;
    int higher_left_digit = (higher_digits_val - higher_right_digit) >> 4;
    score += ((100000 * higher_left_digit) + 10000 * higher_right_digit);
    return score;
}
/* process the latest information from ALE */
void DefenderSettings::step(const System& system) {

    // update the reward
    int mult = 1, score = 0;
    for (int digit = 0; digit < 6; digit++) {
        int v = readRam(&system, 0x9C + digit) & 0xF;
        // A indicates a 0 which we don't display
        if (v == 0xA) v = 0;
        score += v * mult;
        mult *= 10;
    }
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    m_lives = readRam(&system, 0xC2);
    m_terminal = (m_lives == 0);
}
/* process the latest information from ALE */
void MontezumaRevengeSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0x95, 0x94, 0x93, &system); 
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int new_lives = readRam(&system, 0xBA);
    int m_lives = new_lives;
    // if( new_lives < 5){
    // 	//std::cout << "new lives" << new_lives << std::endl;
    // 	m_reward = -10;
    // }
    int some_byte = readRam(&system, 0xFE);
    m_terminal = new_lives == 0 && some_byte == 0x60;
}
/* process the latest information from ALE */
void FrostbiteSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0xCA, 0xC9, 0xC8, &system);
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    // MGB: the maximum achievable life is 9. The system will actually let us set the byte to
    // higher values & properly decrement, but we do not gain lives beyond 9.
    int lives_byte = (readRam(&system, 0xCC) & 0xF);
    int flag  = readRam(&system, 0xF1) & 0x80;
    m_terminal = (lives_byte == 0 && flag != 0);

    m_lives = lives_byte + 1;

}
예제 #20
0
/* extracts a decimal value from a byte */
int getDecimalScore(int index, const System* system) {
    
    int score = 0;
    int digits_val = readRam(system, index);
    int right_digit = digits_val & 15;
    int left_digit = digits_val >> 4;
    score += ((10 * left_digit) + right_digit);    

    return score;
}
예제 #21
0
/* process the latest information from ALE */
void SpaceInvadersSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0xE8, 0xE6, &system);
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int reset_val = readRam(&system, 0xAA);
    reset_val = (reset_val - (reset_val & 15)) >> 4;
    if (reset_val == 8) {
        // game is not reset yet; not end of game
        m_terminal = false; 
    } else {
        // If bit 0x80 is on, then game is over 
        int some_byte = readRam(&system, 0x98); 
        int lives = readRam(&system, 0xC9);
        m_terminal = (some_byte & 0x80) || lives == 0;
    }
}
/* process the latest information from ALE */
void BowlingSettings::step(const System& system) {

    // update the reward
    reward_t score = getDecimalScore(0xA1, 0xA6, &system);
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int round = readRam(&system, 0xA4);
    m_terminal = round > 0x10;
}
예제 #23
0
파일: AirRaid.cpp 프로젝트: 10sun/DRL-AI
/* process the latest information from ALE */
void AirRaidSettings::step(const System& system) {

    // update the reward
    reward_t score = getDecimalScore(0xAA, 0xA9, 0xA8, &system);
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0xA7);
    m_terminal = lives == 0xFF;
}
예제 #24
0
파일: Berzerk.cpp 프로젝트: 10sun/DRL-AI
/* process the latest information from ALE */
void BerzerkSettings::step(const System& system) {

    // update the reward
    reward_t score = getDecimalScore(95, 94, 93, &system);
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0xDA);
    m_terminal = lives == 0xFF;
}
예제 #25
0
/* process the latest information from ALE */
void KungFuMasterSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0x9A, 0x99, 0x98, &system);
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0x9D); 
    m_terminal = lives == 0xFF;
}
예제 #26
0
파일: Carnival.cpp 프로젝트: gandalfvn/EOH
/* process the latest information from ALE */
void CarnivalSettings::step(const System& system) {

    // update the reward
    reward_t score = getDecimalScore(0xAE, 0xAD, &system);
    score *= 10;
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int ammo = readRam(&system, 0x83);
    m_terminal = ammo < 1;
}
/* process the latest information from ALE */
void WizardOfWorSettings::step(const System& system) {

    // update the reward
    reward_t score = getDecimalScore(0x86, 0x88, &system);
    if (score >= 8000) score -= 8000; // MGB score does not go beyond 999
    score *= 100;
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int newLives = readRam(&system, 0x8D) & 15;
    int byte1 = readRam(&system, 0xF4);
    
    bool isWaiting = (readRam(&system, 0xD7) & 0x1) == 0;

    m_terminal = newLives == 0 && byte1 == 0xF8;

    // Wizard of Wor decreases the life total when we move into the play field; we only
    // change the life total when we actually are waiting 
    m_lives = isWaiting ? newLives : m_lives; 
}
예제 #28
0
/* process the latest information from ALE */
void NameThisGameSettings::step(const System& system) {

    // update the reward
    int score = getDecimalScore(0xC6, 0xC5, 0xC4, &system);
    int reward = score - m_score;
    m_reward = reward;
    m_score = score;

    // update terminal status
    int lives = readRam(&system, 0xC7); 
    m_terminal = lives == 0;
}
예제 #29
0
/* process the latest information from ALE */
void AsteroidsSettings::step(const System& system) {

    // update the reward
    reward_t score = getDecimalScore(62, 61, &system);
    score *= 10;
    m_reward = score - m_score;
    m_score = score;

    // update terminal status
    int byte = readRam(&system, 0x3C);
    m_lives = (byte - (byte & 15)) >> 4;
    m_terminal = (m_lives == 0);
}
예제 #30
0
파일: gr909.c 프로젝트: aircross/ray
void RTRVImeth()
{
#ifdef PCM_SLIC_FLOAT		
	double rtr, rtr2, loopVoltage, loopcurrent;
//	doReset();
//	changeCID(0);
//	initialize(); 

	writeRam(VOC,5*TENVOLTINC);
	writeReg(LINEFEED,1);
	delay(1000);
	loopVoltage = -1 *.00492 * (float) readRam(VLOOP);
//	tipVoltage = -1 * .00492 * (float) readRam(VTIP);
//	tipRingVoltage = tipVoltage-ringVoltage;
	
	loopcurrent = -1*(readRam(ILOOP)&0x7FFF) * .000003097;
	
	rtr = loopVoltage/loopcurrent;
	rtr2 = (rtr*800000)/(800000-rtr);
	printf("\nR T-R V over I = %.0f ohms", rtr2);
#endif
}