Skip to content

Oshuma/weewar-spy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weewar-Spy

Based on weewar and weewar-ai, weewar-spy can be used to gather intel on your games.

Requirements

  • RubyGems
  • sudo gem install xml-simple

Runtime-Specific

Development-Specific

  • sudo gem install redgreen
  • sudo gem install Shoulda
  • sudo gem install mocha

Terminology

  • Spy: Something you create and control in the gathering of game and/or user intel
  • Director: You, the library user; implemented as spy.director
  • Shadow, Reconnoiter, Infiltrate: Operations your spy can perform
  • Debrief: How your spy reports its information

Plus the standard Weewar terminology.

Intelligence Gathered

The information returned by the Weewar API is impressive. However, combining a few elements gives you a richer picture of the games you’re playing. If Spy is employed at the beginning of a game then you can track the spending of your opponents. That last statement is not true; version 1.0 can not track spending.

Sample Output

This shows off the highlights of the debrief output. It has been truncated to aid in clarity.

Official Debrief: Lotsa Players
----------------------------------------
Round: 41; Rated: true
Current Player: ntalbott, playing since: Fri Nov 14 03:59:21 UTC 2008
--------------------
  Name: ceoduff; State: finished; Result: surrendered
	Total Units: 10; Troop Strength: 81
	~~~~~~~~~~~~~~~~~~~~
	Extended Troop Info:
	Infantry => Units: 5; Strength: 40
	Vehicles => Units: 3; Strength: 22
	Naval => Units: 2; Strength: 19
	~~~~~~~~~~~~~~~~~~~~
	Total Terrains: 32; Bases: 22
	~~~~~~~~~~~~~~~~~~~~
	Extended Terrain Info:
	Airfields: 4
	Harbors: 6
	~~~~~~~~~~~~~~~~~~~~
	Income: 2200
--------------------
* Name: ntalbott; Points: 1698; On: true
	Total Units: 95; Troop Strength: 829
	~~~~~~~~~~~~~~~~~~~~
	Extended Troop Info:
	Infantry => Units: 24; Strength: 210
	Vehicles => Units: 27; Strength: 250
	Aircraft => Units: 18; Strength: 141
	Naval => Units: 26; Strength: 228
	~~~~~~~~~~~~~~~~~~~~
	Total Terrains: 91; Bases: 59
	~~~~~~~~~~~~~~~~~~~~
	Extended Terrain Info:
	Airfields: 12
	Harbors: 20
	~~~~~~~~~~~~~~~~~~~~
	Income: 5900
----------------------------------------
For Director Mriffe, on: Fri Nov 14 02:25:58 -0500 2008
========================================

The splat ( * ) is to quickly locate the current player.

Usage Examples

The idea is to create a Spy, controlled by you, to gather intel on the games you’re playing. There will be a number of examples and tests from which to learn how to Spy.

Currently Spy is employed upon command. It is up to you to execute a script and to capture the output.

Caution: Spy was tested and developed against a small number of games. If you have a large number of games I suggest infiltrating one game at a time. The example provided loops through the director’s games and may not be appropriate for users involved in a number of large games. YMMV

Creating A Spy

  class BlackSpy < WeewarSpy::Spy
    def initialize
      super(
        :server => 'server',   # usually 'weewar.com'
        :username => 'mriffe',
        :api_key => 'apiToken'
      )
    end
  end
  
  spy = BlackSpy.new

You have to create a subclass of WeewarSpy::Spy, passing in the target server (‘weewar.com’), your Weewar username, and your Weewar API Token.

Upon initialization, spy will retrieve your user information and the list of games in which you are playing.

  games = spy.games  # returns a hash of game ids to game names
  games = games.sort # sort the hash into an array of arrays. ex: [[1234, 'Thermonuclear War'], [5678, 'Fight to the Death']]
  game_id = games.first[0] # first element of the first game in the array is the id of that game (see above)

Infiltrating a Game

  # Takes a game id (integer).
  game = spy.infiltrate(game_id)

This operation is the most useful as it gathers the most information about a running game. From this operation you can gather information on another player’s troop strength, how many bases they have, and current income level.

Reconnoitering a Game

  # Takes a game id (integer).
  game = spy.reconnoiter(game_id)

This operation returns basic information about a game, such as number of players, round, type, etc. This is a lighter operation compared to ‘infiltrate’ but isn’t as useful. Note: spy.debrief expects an infiltrated game.

Shadowing a Player

  player = game.players.first.name # their Weewar username
  spy.shadow(player)

Shadowing a player allows you to gather information about their points, games they’re playing, and the players they prefer, etc. Note: You can not gather information about a player’s game that you are not playing. That is a constraint enforced by Weewar.

Debriefing a Game

  # Takes a WeewarSpy::Game instance.
  spy.debrief(game)

Debriefing currently only works with infiltrated games as it prepares a pseudo-report of the information gathered about a game. This operation will also be used often to review the information found during spying.

Issues and Enhancement Requests

This project is using No Kahuna to track tasks and issues. The project is located here: http://nokahuna.com/projects/3186

Authors and Contributors

Original by Mel Riffe; by extension the authors and contributors of ‘weewar’ and ‘weewar-ai’ are included.
29 October 2008

About

Ruby bindings over Weewar's API to gather information about the games you're playing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%