Skip to content

Commit

Permalink
Code review feedback for Solver.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenbensley committed Jun 18, 2023
1 parent 84beeb4 commit 79bd8f4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions QueahEngine/Solver/GameNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ GameNode::GameNode(GamePosition pos) noexcept
: pos_(pos)
{ }

bool GameNode::terminal() const noexcept
{
return children_.empty();
}

GamePosition GameNode::position() const noexcept
{
return pos_;
Expand All @@ -27,6 +22,11 @@ ValueType GameNode::value() const noexcept
return value_;
}

bool GameNode::terminal() const noexcept
{
return children_.empty();
}

ValueType GameNode::min_child_value() const noexcept
{
auto i = std::min_element(children_.begin(),
Expand Down
4 changes: 2 additions & 2 deletions QueahEngine/Solver/Solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ GameNode* find_or_create(NodeMap& nodes, GamePosition pos)

// Recursively find and insert the children. Note: We must insert the parent
// node before creating the children since there may be loops in the graph.
for (auto m : key.moves()) {
node->insert_child(find_or_create(nodes, key.try_move(m)));
for (auto move : key.moves()) {
node->insert_child(find_or_create(nodes, key.try_move(move)));
}

// Return a pointer to the newly inserted node.
Expand Down
5 changes: 2 additions & 3 deletions QueahEngine/Solver/Solve.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define Solve_h

#include "GameNode.h"
#include "PositionEvaluator.h"
#include <memory>
#include <vector>

Expand All @@ -19,10 +18,10 @@ using GameNodePtrs = std::vector<GameNodePtr>;
// Constructs all the nodes in the game tree.
GameNodePtrs build_nodes();

// Compute the value of all the game positions.
// Computes the values of all the game positions.
void compute_values(const GameNodePtrs& nodes) noexcept;

// Convert GameNodePtrs to PositionValues.
// Converts GameNodePtrs to PositionValues.
PositionValues to_position_values(const GameNodePtrs& nodes);

#endif /* Solve_h */
4 changes: 2 additions & 2 deletions QueahEngine/Solver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

int main(int argc, const char * argv[])
{
const char datafile[] = "queah.solution";
const char datafile[] = "queah.dat";

std::cout << "Building nodes ..." << std::endl;
auto nodes = build_nodes();
Expand All @@ -38,7 +38,7 @@ int main(int argc, const char * argv[])
std::cout << "Done." << std::endl;

if (!eval.load(datafile)) {
std::cout << "Verification failed." << std::endl;
std::cout << "Data file verification failed." << std::endl;
}

return 0;
Expand Down

0 comments on commit 79bd8f4

Please sign in to comment.