#ifndef __EXEC_TRAIL_HPP__ #define __EXEC_TRAIL_HPP__ /* "Species" - a CoreWars evolver. Copyright (C) 2004 'Varfar' * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 1, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "exhaust.hpp" #include class COpcodeMap { public: COpcodeMap(); unsigned opmap(field_t field) const; unsigned segments() const { return 10; } // arb unsigned optypes() const { return MAX_OPTYPES; } unsigned segsize() const { return 80000/segments(); } private: enum OPTYPE { SPLIT, MOVI, MATH, BRANCH, OTHER, MAX_OPTYPES } _opmap[MAX_OPCODES]; void mapop(OPCODE op,OPTYPE type); void mapop(OPCODE op,MODIFIER mod,OPTYPE type); void makeopmap(); }; class CExecTrail { public: typedef unsigned long long dist_t; CExecTrail(COpcodeMap *map); ~CExecTrail(); void clear(); bool load_from_file(const char *filename); // returns success std::string filename() const { return _filename; } void set(unsigned const segment,dist_t table[MAX_OPCODES]); // table[SEGMENTS][MAX_OPCODES] dist_t distance_squared(CExecTrail const *other) const; dist_t max_distance_from() const; private: std::string _filename; static const dist_t ZERO = 0ull; static const dist_t BLOODY_MASSIVE = 0xFFFFFFFFFFFFFFFFull; COpcodeMap *_map; dist_t **_exec_count; }; #endif // __EXEC_TRAIL_HPP__