Data structure for optimization on a discrete space
Go to file
Stu Black fbe8c57872 Pulled out cycle detection code. Graph now has no intrinsic notion of cycles.
This code identified cycles by marking edges on a root-node path R, ...,
A, ..., X with the Target::Cycle variant when there was already some
other path R, ..., B, ..., X. This successfully induced an acyclic graph
structure while maintaining the topology of which vertices are reachable
along a given path, but it did not serve the general interest of
constructing a graph for MCTS for a couple of reasons:

1) Parent-child edges with a Target::Cycle target did not have a
   corresponding child-parent edge, so it became harder to do the right
   thing in backpropagation.
2) Without more concrete control over which paths are considered the
   canonical owner of a vertex, it is possible that a suboptimal
   path (which goes through some nodes that admit very strong opponent
   play) would be the canonical path. This could prevent discovery of a
   very good move.
2016-02-14 19:16:50 -05:00
src Pulled out cycle detection code. Graph now has no intrinsic notion of cycles. 2016-02-14 19:16:50 -05:00
.gitignore Factored out into its own thing, with code more neatly organized. 2016-01-22 20:56:07 -05:00
Cargo.toml Change package name to match Rust conventions. 2016-01-24 18:19:44 -05:00
LICENSE Factored out into its own thing, with code more neatly organized. 2016-01-22 20:56:07 -05:00
README.org Factored out into its own thing, with code more neatly organized. 2016-01-22 20:56:07 -05:00

Overview

This package provide a rollout-based, DAG-like data structure. Its intended use is building game state graphs for general game-playing or similar AI tasks.

Vertices correspond to game states. They are addressed by unique game states (which may be de-duplicated as if by transposition table by implementing std::hash::Hash and std::cmp::Eq appropriately for your game state type).

Edges correspond to game-modifying moves. They are bidirectional, so paths may be traced up and down the graph.

The structure is rollout-based in that edges are expanded lazily. This should make it easy to implement planning algorithms like A* and Monte Carlo tree search on top of the DAG structure.

It is DAG-like in that it nominally maintains a cycle-free topology by checking for cycles at edge expansion time and noting which edges would create cycles when they are expanded. Such edges are added to the graph as half-edges, which are only present in one direction. Unfortunately, checking for cycles leads to O(|V|) running time when adding vertices.

At present, the graph topology may be grown but not pruned. Vertex and edge deletion may be supported in a future version.

Copyright

Copyright 2015-2016, Donald S. Black.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.