42 CNeuralNet(w*h, seed), m_nWidth(w), m_nHeight(h), m_nSize(w*h)
45 for(
int srcx=0; srcx<
m_nWidth; srcx++){
46 const int src = srcy*
m_nWidth + srcx;
49 const int destx = srcx + delta.first;
52 const int desty = srcy + delta.second;
55 const int dest = desty*
m_nWidth + destx;
86 int newstate = pNeuron->
GetState() + 4;
89 pEdge->GetVertexIndices(v0, v1);
91 for(
UINT v: {v0, v1}){
94 for(
CEdge* pEdge2: *adj)
95 if(((
CNeuron*)pEdge2)->GetOutput())
101 if(newstate > 3)pNeuron->
SetOutput(
true);
102 else if(newstate < 0)pNeuron->
SetOutput(
false);
140 bool bDegree2 =
true;
143 bDegree2 = bDegree2 && degree[i] == 2;
154 bool bFinished =
false;
155 bool bStable =
false;
161 for(
int j=0; j<400 && !bStable; j++)
190 CEdge* pEdge =
nullptr;
193 for(
auto it=(*adj).begin(); it!=(*adj).end(); it++){
206 while(cur != start && !cur->
Marked()){
209 CEdge* pNextEdge =
nullptr;
212 for(
auto it=(*adj).begin(); it!=(*adj).end(); it++){
214 if(pNeuron->
GetOutput() == 1 && (*it) != pEdge){
239 if(p ==
nullptr)
return;
243 for(
CEdge* pEdge: *adjacencylist){
244 CVertex* pNext = pEdge->GetNextVertex(p);
255 for(
size_t i=0; i<n; i++){
CVertex * GetNextVertex(CVertex *p)
Get vertex at other end of edge.
int GetState()
Get neuron state.
bool IsStable()
Stability test.
std::atomic_bool g_bFinished
Search termination flag.
UINT GetIndex()
Get index;.
bool HasDegree2()
Degree test.
Header for the neural network tourney generator CTakefujiLee.
void GraphToBoard(CBoard &b)
Convert graph to board.
Defines, enumerated types, and typedefs.
void SetOutput(bool b)
Set neuron output.
bool GetOutput()
Get neuron output.
CRandom m_cRandom
Random number generator.
void Mark(bool b=true)
Mark or unmark.
Neuron in a Hopfield network.
MoveDeltas g_vecDeltas
Move deltas for all possible knight's moves.
UINT randn()
Get a random unsigned integer.
int m_nHeight
Board height.
float randf()
Get a random floating point number.
Header for helper functions.
void GetAdjacentVertices(std::vector< CVertex * > &v, CVertex *p)
Get adjacent vertices.
std::vector< CEdge * > m_vEdgeList
Edge list.
unsigned int UINT
Abbreviation for unsigned integer.
CTakefujiLee(int w, int h, int seed)
Constructor.
void SetState(int n)
Get neuron state.
bool Update()
Update all neurons.
Header for the pseudo-random number generator CRandom.
UINT m_nNumVerts
Number of vertices.
Header for the chessboard CBoard.
void InsertNeuron(UINT i, UINT j)
Insert a neuron.
void Generate(CBoard &b)
Generate a tourney.
std::vector< CEdge * > * GetAdjacencyList()
Get adjacency list.
std::vector< MoveDelta > MoveDeltas
Move deltas for knight's moves.
void RandomizeEdgeList()
Randomize the edge list.
CVertex * m_pVertexList
Vertex list.
bool InsertUndirectedMove(int src, int dest)
Insert an undirected move.
void Clear()
Clear the board of moves.
void GetVertexIndices(UINT &i0, UINT &i1)
Get vertex indices.