trylobot / hive Goto Github PK
View Code? Open in Web Editor NEWHive AI Development Tool - http://gen42.com/hive-carbon
License: Other
Hive AI Development Tool - http://gen42.com/hive-carbon
License: Other
Right-Click + Drag: Pan View (Immediate)
Mousewheel Up/Down: Zoom In/Out (Smoothed)
Add "marquee" tile sprite, for displaying possible move locations.
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..."
JSON-Schema draft 4 supports typed maps with arbitrary properties (keys), and allows for defining subtypes and referencing them elsewhere. Use it for validating comms. between AI modules and core game engine.
http://stackoverflow.com/questions/17947249/support-for-stdmap-stdstring-t-in-json-schema
Currently Host background retains winner status (black/white)
Web interface will not work, move-crunching on serverside will not scale. Transform app into a fat client built with Node-Webkit.
Cannot complete a game. Get maybe 5 turns in, only.
Use small icons and text multipliers to show the hand on-screen, in the status bar area.
This will require some icon cleanup.
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.
Broke during demo, with a Soldier Ant
Refactor board.can_slide_lookup_table
to use bit strings instead of character strings, and everywhere that deals with them to use bitwise operators.
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.
Piece.colors_map
Piece.types_map
Position.coplanar_directions_map
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.
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.
When dragging a moveable piece, show the origin position with some kind of special indicator
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 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.
interactionData.getLocalCoordinates( this.parent );
will always work, because position is always relative to an object's parent.
Use ansi-font to produce pretty-printed boards with colors.
Sometimes pieces move around in weird ways when beetles are moving atop the hive. Not sure if it's a bug with the UI or with the core domain objects.
per Charlie Hedlin
Its presence uneqivocally indicates that no other move is possible, and that the player must forfeit the turn.
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.
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.
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.
And provide a basic javascript web container to wrap the provided AI modules, as an example for other platforms.
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.
I maximized the window but the hit_rect was the same size as the original window. (windows 7)
The Player class should completely encapsulate the concept of a player, and should raise and handle events for board changes and such.
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.
This function needs to resemble the following:
position.adjacent( "0,0" )
> [ "-2,0", "-1,1", "1,1", "2,0", "1,-1", "-1,-1" ]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.