Crate ggp_rs [−] [src]
A library for creating General Game Playing (GGP) players. This library is based off of GGP Base. While GGP Base allows the creation of players backed by a propositional network or a logic prover, this library currently only supports logic prover based players.
Example
To create your own player, simply implement the Player
trait for your struct and pass the
host/port you want the player to run at and the player itself to the run
function.
The following example implements a RandomPlayer, which plays random legal moves each turn.
extern crate rand; extern crate ggp_rs; use ggp_rs::{Player, Game, Move}; use std::net::Ipv4Addr; struct RandomPlayer; impl Player for RandomPlayer { fn name(&self) -> String { "RandomPlayer".to_string() } fn select_move(&mut self, game: &Game) -> Move { let state = game.current_state(); let role = game.role(); let mut moves = game.legal_moves(state, role); let r = rand::random::<usize>() % moves.len(); moves.swap_remove(r) } } fn main() { ggp_rs::run((Ipv4Addr::new(0,0,0,0), 9147), RandomPlayer); }
Modules
player |
Ready to use GGP players |
Macros
check_time! |
Checks whether we are out of time, and if so, returns the move selected by
|
check_time_result! |
Checks whether we are out of time, and if so, returns the move selected by
|
Structs
Game |
A description of a game. The methods of this object use a logic prover to find all true statements that satisfy a given query (i.e. find all legal moves). Note that queries are cached, so calling a method that performs a query twice will only pay for any necessary clones, another query will not be performed. |
Move |
A move in a game |
Role |
A role in a game |
State |
The state of a game, containing all |
Traits
Player |
A GGP player |
Functions
run |
Starts a GGP player listening at |
Type Definitions
MoveResult |
This type meant to be used in GGP players for returning a move when time runs out. For
functions that would normally have a return type |
Score |
The score a player can get at a goal state |