mobilityTable.h
Go to the documentation of this file.
/* mobilityTable.h
*/
#ifndef _MOBILITY_TABLE_H
#define _MOBILITY_TABLE_H
#include "osl/basic_type.h"
#include "osl/simpleState.h"
#include <cassert>
#include <iosfwd>
namespace osl
{
namespace mobility
{
union V4 {
unsigned int lv;
CArray<unsigned char,4> uc;
}
#ifdef __GNUC__
__attribute__((aligned(4)))
#endif
;
class MobilityContent
{
V4 v;
public:
MobilityContent() {
clear();
}
void clear(){
v.lv=0u;
}
const Square get(Direction d) const{
return Square::makeDirect(v.uc[((unsigned int)d)>>1]);
}
void set(Direction d,Square pos){
v.uc[((unsigned int)d)>>1]=static_cast<unsigned char>(pos.uintValue());
}
};
std::ostream& operator<<(std::ostream& os,MobilityContent const& mc);
class MobilityTable
{
CArray<MobilityContent,8> table
#ifdef __GNUC__
__attribute__((aligned(16)))
#endif
;
public:
MobilityTable(){}
MobilityTable(SimpleState const& state);
void set(Direction d,int num,Square pos){
assert(0<=(int)d && (int)d<=7);
return table[num-32].set(d,pos);
}
const Square get(Direction d,int num) const{
assert(0<=(int)d && (int)d<=7);
return table[num-32].get(d);
}
friend bool operator==(const MobilityTable& mt1,const MobilityTable& mt2);
};
std::ostream& operator<<(std::ostream& os,MobilityTable const& mt);
bool operator==(const MobilityTable&,const MobilityTable&);
}
using mobility::MobilityTable;
}
#endif /* _MOBILITY_TABLE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
basic_type.h
osl::CArray
Definition container.h:20
osl::SimpleState
Definition simpleState.h:35
osl::Square
Definition basic_type.h:532
osl::Square::uintValue
unsigned int uintValue() const
Definition basic_type.h:539
osl::Square::makeDirect
static const Square makeDirect(int value)
Definition basic_type.h:538
osl::mobility::MobilityContent::clear
void clear()
Definition mobilityTable.h:36
osl::mobility::MobilityContent::set
void set(Direction d, Square pos)
Definition mobilityTable.h:42
osl::mobility::MobilityContent::MobilityContent
MobilityContent()
Definition mobilityTable.h:33
osl::mobility::MobilityContent::get
const Square get(Direction d) const
Definition mobilityTable.h:39
osl::mobility::MobilityContent::v
V4 v
Definition mobilityTable.h:31
osl::mobility::MobilityTable
駒番号からMobilityContentを得る
Definition mobilityTable.h:52
osl::mobility::MobilityTable::operator==
friend bool operator==(const MobilityTable &mt1, const MobilityTable &mt2)
osl::mobility::MobilityTable::get
const Square get(Direction d, int num) const
Definition mobilityTable.h:65
osl::mobility::MobilityTable::set
void set(Direction d, int num, Square pos)
Definition mobilityTable.h:61
osl::mobility::MobilityTable::MobilityTable
MobilityTable()
Definition mobilityTable.h:59
osl::mobility::MobilityTable::table
CArray< MobilityContent, 8 > table
Definition mobilityTable.h:57
osl::mobility
Definition bishopMobility.h:11
osl::mobility::operator==
bool operator==(const MobilityTable &, const MobilityTable &)
Definition mobilityTable.cc:49
osl::mobility::operator<<
std::ostream & operator<<(std::ostream &os, MobilityContent const &mc)
Definition mobilityTable.cc:28
osl::mobility::__attribute__
long long v2di __attribute__((vector_size(16)))
Definition kingMobility.h:22
osl
Definition additionalEffect.h:6
osl::Direction
Direction
Definition basic_type.h:310
simpleState.h
osl::mobility::V4
Definition mobilityTable.h:14
osl::mobility::V4::uc
CArray< unsigned char, 4 > uc
Definition mobilityTable.h:16
osl::mobility::V4::lv
unsigned int lv
Definition mobilityTable.h:15