Git Product home page Git Product logo

hive's People

Contributors

trylobot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hive's Issues

Add unit test for board.can_slide_lookup_table

For each key in board.can_slide_lookup_table, generate five additional rotated versions of that key (rotated in 60 degree increments), and verify that each value for each of those six keys match.

I'll need a new util function for this, which should resemble the below. First argument is the string, second argument is the number of characters to shift. Shifted characters are removed from the end of the string one-by-one and prefixed onto the start in the same order they were removed. This will be useful for rotating slide lookup keys.

shift_string( ".1...1", 1 )
> "1.1..."

Rematch

Currently Host background retains winner status (black/white)

Show Hand (interactive, dynamic)

Use small icons and text multipliers to show the hand on-screen, in the status bar area.
This will require some icon cleanup.

ØMQ AI plugin interface

Every ØMQ AI plugin will be expected to implement an interface that will allow the game server to request moves from it. The game server can connect to the AI plugin over any transport that ØMQ supports. The AI plugin is given a board state and a list of possible moves (in stringified JSON format), and is expected to return one of them.

/*
GREETINGS request
  this request type is used to establish the identity of a remote AI module
  and also to inform the module about the semantic version string of the system.
*/

// example request structure sent from the game core to an AI module
{
  request_type: "GREETINGS",
  system_version: "0.0.1"
}
// example response structure sent back to the server for the above request
{
  response_type: "GREETINGS",
  name: "Rando[m]",
  version: "0.0.1",
  author: "T.W.R. Cole",
  project_url: "https://github.com/user/project",
  language: "Javascript"
}
/*
CHOOSE_TURN request
  this request type is used to request turns from remote AI modules.
  the possible turns are enumerated in advance, and the AI is expected to choose one.
  the board state and the contents of each players' hand is also given.
  there is no explicit limit on think-time.
*/

// example request structure sent from the game core to an AI module
{
  request_type: "CHOOSE_TURN",
  game_id: "d1446da0-f105-11e3-aa3c-0002a5d5c51b",
  possible_turns: {
    "Placement": [ 
      "-2,0",
      "-1,-1", 
      "1,-1"
    ],
    "Movement": {
      "0,0": [
        "2,0",
        "-1,1"
      ]
    }
  },
  game_state: {
    board: {
      pieces: {
        "0,0": [
          {
            color: "White",
            type: "Queen Bee"
          }
        ],
        "1,1": [
          {
            color: "Black",
            type: "Queen Bee"
          },
          {
            color: "Black",
            type: "Beetle"
          }
        ]
      }
    },
    hands: {
      "White": {
        "Soldier Ant": 2,
        "Grasshopper": 1
      },
      "Black": {}
    },
    player_turn: "White",
    turn_number: 2,
    game_over: false,
    winner: null,
    is_draw: false
  }
}
// example response structure sent back to the server for the above request
{
  response_type: "CHOOSE_TURN",
  game_id: "d1446da0-f105-11e3-aa3c-0002a5d5c51b",
  turn_type: "Placement",
  piece_type: "Soldier Ant",
  destination: "-1,-1"
}
// another example, for a different turn_type
{
  response_type: "CHOOSE_TURN",
  game_id: "d1446da0-f105-11e3-aa3c-0002a5d5c51b",
  turn_type: "Movement",
  source: "0,0",
  destination: "2,0"
}

By default, the game runs in human-versus-human mode. At any time, one or both of the players can be replaced with an AI plugin. This can be done at startup via either a command-line switch or the config file, or during play. Likewise, at any time, an AI plugin can be disabled and its associated player reverted back to human mode.

If the game is started in AI-versus-AI mode, it can show the game progress as normal in a speed-throttled visual mode, or show only final game states in high-speed mode. There is also a batch/aggregate mode wherein a pool of AI plugins is defined, and the game will play many games and aggregate them up into tabular statistics for each AI versus each other AI. Optionally the final game states for each of those games can be output as well; these will be in the form of HTML files pre-loaded with the game state information, such that if they are viewed in a browser they show the game result in a non-interactive mode resembling normal human-versus-human play.

Global Refactoring: Use Strings as Enums

Since Javascript strings are immutable, it will be a lot more user-friendly to use strings as enums instead of the more complicated int - string relationship currently present in the code.

  • Remove Piece.colors_map
  • Remove Piece.types_map
  • Remove Position.coplanar_directions_map
  • Remove Position.layer_directions_map

An enum will now be defined as a list of strings. If a piece of code needs to iterate over all possible enum values, it will iterate over the definition list, whever it lives.

Mac: Board disappears, Board won't load

Sometimes the board disappears.
Sometimes when you load a game, nothing happens (board doesn't load).
No errors printed to console.
Reloading the same game does not necessarily reproduce.

Core - Memory leak audit

I suspect closures are being created as a side effect of my {Module}.create(...) pattern, because in at least one place the object returned is referencing variables created in the scope of the object creation function; if the object is deleted, the scope probably will not be destroyed because it actually belongs to the module itself, and so will probably remain in memory.

// DO this
function create() {
  return new (function ModuleObject() {
    var self = this;
    self.x = 5;
    self.add = function() {
      self.x++;
    }
  })();
}

// DON'T do this
function create() {
  var x = 5;
  var module_object = {
    x: x
  }
  module_object.add = function() {
    module_object.x++;
  }
  return module_object;
}

Use node/net (TCP) instead of node/http (HTTP)

Use node/net (TCP sockets) for all networked communications. This means getting rid of node/http and express from core game functions, hive-cli and node-webkit, along with supporting the latest documented API format.

Also, refactor hive-cli and node-webkit such that they no longer care about networking, but rather use asynchronous events, with the network communication being incorporated into the core/domain objects for all to share.

Piece rotation

Add random rotation to pieces newly placed (normalized to the six natural orientations).
Add ability to rotate any piece that is already on the board.

Isometric pseudo-3D sprites

For the hex tile template, this will be as easy as pre-squishing the hex shape and adding three sides statically.

For the marquee, it will be pre-squished also.

For the symbols, I'll need to create 6 versions of each sprite, pre-squished by the same amount (or squished programmatically), representing the 6 rotations of the symbol at the correct perspective to be superimposed upon a hex tile template.

For the hand tiles, they should be stacks of pieces as well

Displaying isometric sprites has a couple of implications.

  • all tiles at height 1 are on top of all tiles at height 0
  • for tiles at the same height, a tile in row 1 is on top of a tile in row 0
  • column has no bearing on display order

Since a stack of pieces can obscure pieces behind it, the user needs to be able to rotate the board. 6 orientations should be sufficient.

It also seems that a user might want to switch back to the top-down view, just because.

Show Stack Contents

When hovering over a stack of size > 1, when hover-intent fires (did not mouse-out for amount of time), show the contents of the stack somehow. Maybe a bubble / callout, off to the side of the piece.

Use a magnifying glass as the icon. Will need white version & black version.

Refactor board.pieces

Refactor board.pieces such that position keys refer to piece stacks rather than individual pieces. Piece stacks are lists of piece objects, with index N-1 (where N is the size of the stack) being the topmost piece in that stack.

Currently, board.pieces looks like this:

pieces: {
  "0,0,0": { color: 0, type: 0 },
  "0,1,0": { color: 1, type: 0 },
  "0,0,1": { color: 1, type: 1 }
}

But I want it to look like this instead:

pieces: {
  "0,0": [
    { color: 0, type: 1 },
    { color: 1, type: 0 }
  ],
  "0,1": [
    { color: 1, type: 0 }
  ]

I also need to modify board.lookup_piece to support the new organizational scheme and return the topmost piece for lookups.

Add method: position.adjacent

This function needs to resemble the following:

position.adjacent( "0,0" )
> [ "-2,0", "-1,1", "1,1", "2,0", "1,-1", "-1,-1" ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.