<commit_before>#include "object.h"
#include "object_attack.h"
#include "stimulation.h"
#include "util/ebox.h"
#include <math.h>
#include <exception>
#include <iostream>

using namespace std;

#ifndef debug
#define debug cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<<endl;
#endif

/*
const int Object::FACING_LEFT = 0; 
const int Object::FACING_RIGHT = 1;
*/

Object::Object( int alliance ):
actualx( 0 ),
actualy( 0 ),
actualz( 0 ),
virtualx( 0 ),
virtualy( 0 ),
virtualz( 0 ),
health( 0 ),
max_health( 0 ),
damage( 0 ),
facing( FACING_RIGHT ),
alliance( alliance ),
id( 0 ){
}

Object::Object( const int x, const int y, int _alliance ):
actualx( x ),
actualy( 0 ),
actualz( y ),
virtualx( (double)x ),
virtualy( 0 ),
virtualz( (double)y ),
health( 0 ),
max_health( 0 ),
damage( 0 ),
facing( FACING_RIGHT ),
alliance( _alliance ),
id( 0 ){
}

Object::Object( const Object & copy ):
damage( 0 ){
	actualx = copy.actualx;
	actualy = copy.actualy;
	actualz = copy.actualz;
	virtualx = copy.virtualx;
	virtualy = copy.virtualy;
	virtualz = copy.virtualz;
	facing = copy.facing;
	health = copy.health;
	hit = copy.hit;
	id = copy.id;
	setMaxHealth( copy.getMaxHealth() );
	setAlliance( copy.getAlliance() );
}
	
double Object::ZDistance( const Object * obj ){
	return fabs( obj->getZ() - getZ() );
	/*
	if ( obj->getZ() > getZ() )
		return obj->getZ() - getZ();
	return getZ() - obj->getZ();
	*/
}
	
double Object::XDistance( const Object * obj ){
	if ( obj->getX() > getX() )
		return obj->getX() - getX();
	return getX() - obj->getX();
}

/* move in an absolute direction */
void Object::moveRight( const int x ){
	moveX( FACING_RIGHT, x );
}

void Object::moveLeft( const int x ){
	moveX( FACING_LEFT, x );
}
	
void Object::stimulate( const Stimulation & stim ){
	stim.stimulate( *this );
}
	
void Object::moveX( int dir, const int x ){
	if ( dir == getFacing() ){
		moveX( x );
	} else {
		moveX( -x );
	}
}

void Object::faceObject( const Object * o ){
	if ( o->getX() < getX() ){
		setFacing( Object::FACING_LEFT );
	} else {
		setFacing( Object::FACING_RIGHT );
	}
}

void Object::thrown(){
}
	
void Object::moveX( const int x ){
	moveX( (double)x );
}

void Object::died( vector< Object * > & objects ){
}

void Object::moveY( const int y ){
	moveY( (double)y );
}

void Object::moveZ( const int z ){
	moveZ( (double)z );
}

void Object::moveX( double x ){

	if ( getFacing() == FACING_LEFT ){
		virtualx -= x;
	} else {
		virtualx += x;
	}

	actualx = (int)virtualx;
}

void Object::moveY( double y ){
	virtualy += y;
	actualy = (int)virtualy;
	if ( actualy < 0 ){
		virtualy = 0;
		actualy = 0;
	}
}
	
const int Object::getAlliance() const{
	return alliance;
}
	
void Object::collided( ObjectAttack * obj, vector< Object * > & objects ){
	hit.play();
}

void Object::moveZ( double z ){
	virtualz += z;
	actualz = (int)virtualz;
}

void Object::print() const{
}
	
void Object::interpretMessage( Network::Message & message ){
	int type;
	message >> type;
	switch ( type ){
		case OBJECT_MOVED : {
			int x, y, z, facing;
			message >> x >> y >> z >> facing;
			setX( x );
			setY( y );
			setZ( z );
			setFacing( facing );
			break;
		}
	}
}

Network::Message Object::movedMessage(){
	Network::Message m;

	m.id = getId();
	m << OBJECT_MOVED;
	m << (int) getX();
	m << (int) getY();
	m << (int) getZ();
	m << getFacing();

	return m;<commit_msg>send x decimal in movement message<commit_after>#include "object.h"
#include "object_attack.h"
#include "stimulation.h"
#include "util/ebox.h"
#include <math.h>
#include <exception>
#include <iostream>

using namespace std;

#ifndef debug
#define debug cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<<endl;
#endif

/*
const int Object::FACING_LEFT = 0; 
const int Object::FACING_RIGHT = 1;
*/

Object::Object( int alliance ):
actualx( 0 ),
actualy( 0 ),
actualz( 0 ),
virtualx( 0 ),
virtualy( 0 ),
virtualz( 0 ),
health( 0 ),
max_health( 0 ),
damage( 0 ),
facing( FACING_RIGHT ),
alliance( alliance ),
id( 0 ){
}

Object::Object( const int x, const int y, int _alliance ):
actualx( x ),
actualy( 0 ),
actualz( y ),
virtualx( (double)x ),
virtualy( 0 ),
virtualz( (double)y ),
health( 0 ),
max_health( 0 ),
damage( 0 ),
facing( FACING_RIGHT ),
alliance( _alliance ),
id( 0 ){
}

Object::Object( const Object & copy ):
damage( 0 ){
	actualx = copy.actualx;
	actualy = copy.actualy;
	actualz = copy.actualz;
	virtualx = copy.virtualx;
	virtualy = copy.virtualy;
	virtualz = copy.virtualz;
	facing = copy.facing;
	health = copy.health;
	hit = copy.hit;
	id = copy.id;
	setMaxHealth( copy.getMaxHealth() );
	setAlliance( copy.getAlliance() );
}
	
double Object::ZDistance( const Object * obj ){
	return fabs( obj->getZ() - getZ() );
	/*
	if ( obj->getZ() > getZ() )
		return obj->getZ() - getZ();
	return getZ() - obj->getZ();
	*/
}
	
double Object::XDistance( const Object * obj ){
	if ( obj->getX() > getX() )
		return obj->getX() - getX();
	return getX() - obj->getX();
}

/* move in an absolute direction */
void Object::moveRight( const int x ){
	moveX( FACING_RIGHT, x );
}

void Object::moveLeft( const int x ){
	moveX( FACING_LEFT, x );
}
	
void Object::stimulate( const Stimulation & stim ){
	stim.stimulate( *this );
}
	
void Object::moveX( int dir, const int x ){
	if ( dir == getFacing() ){
		moveX( x );
	} else {
		moveX( -x );
	}
}

void Object::faceObject( const Object * o ){
	if ( o->getX() < getX() ){
		setFacing( Object::FACING_LEFT );
	} else {
		setFacing( Object::FACING_RIGHT );
	}
}

void Object::thrown(){
}
	
void Object::moveX( const int x ){
	moveX( (double)x );
}

void Object::died( vector< Object * > & objects ){
}

void Object::moveY( const int y ){
	moveY( (double)y );
}

void Object::moveZ( const int z ){
	moveZ( (double)z );
}

void Object::moveX( double x ){

	if ( getFacing() == FACING_LEFT ){
		virtualx -= x;
	} else {
		virtualx += x;
	}

	actualx = (int)virtualx;
}

void Object::moveY( double y ){
	virtualy += y;
	actualy = (int)virtualy;
	if ( actualy < 0 ){
		virtualy = 0;
		actualy = 0;
	}
}
	
const int Object::getAlliance() const{
	return alliance;
}
	
void Object::collided( ObjectAttack * obj, vector< Object * > & objects ){
	hit.play();
}

void Object::moveZ( double z ){
	virtualz += z;
	actualz = (int)virtualz;
}

void Object::print() const{
}
	
void Object::interpretMessage( Network::Message & message ){
	int type;
	message >> type;
	switch ( type ){
		case OBJECT_MOVED : {
			int x, y, z, facing;
			int xfrac;
			message >> x >> xfrac >> y >> z >> facing;
			setX( x + xfrac / 100.0 );
			setY( y );
			setZ( z );
			setFacing( facing );
			break;
		}
	}
}

Network::Message Object::movedMessage(){
	Network::Message m;

	m.id = getId();
	m << OBJECT_MOVED;
	m << (int) getX();
	/* include the decimal part of x */
	m << (int) ((getX() - (int) getX()) * 100);
	m << (int) getY();
	m << (int) getZ();
	m << getFacing();

	return m;
{'fraction_non_alphanumeric': 0.18021046477638117, 'fraction_numerical': 0.007453960830166618, 'mean_word_length': 3.755385684503127, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6574074', 'n_tokens_mistral': 2779, 'n_tokens_neox': 2627, 'n_words': 713}