{"action":"created","comment":{"url":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/comments/91859270","pull_request_review_id":12369469,"id":91859270,"diff_hunk":"@@ -1333,20 +1338,162 @@ function torchcraft:get_layer(layer_type, also_enemy)\n                                        32, 32, color)\n             end\n         end\n+    elseif layer_type == \"minerals\" then\n+        t = self.state.units_neutral\n+        for uid, ut in pairs(t) do\n+            if self:is_unit_in_screen(ut) and utils.is_mineral_field(ut) then\n+                pos_x, pos_y = self:get_unit_screen_pos(ut)\n+                color = utils.get_health_color(ut.resource, 1500)\n+                img = self:draw_entity(img, pos_x, pos_y,\n+                                       ut.pixel_size_x, ut.pixel_size_y, color)\n+            end\n+        end\n+    elseif layer_type == \"gas\" then\n+        t = tablex.merge(t, self.state.units_neutral, true);\n+        for uid, ut in pairs(t) do\n+            if self:is_unit_in_screen(ut) and utils.is_gas_geyser(ut) then\n+                pos_x, pos_y = self:get_unit_screen_pos(ut)\n+                color = utils.get_health_color(ut.resource, 2500)\n+                img = self:draw_entity(img, pos_x, pos_y,\n+                                       ut.pixel_size_x, ut.pixel_size_y, color)\n+            end\n+        end\n     else\n         for uid, ut in pairs(t) do\n             if self:is_unit_in_screen(ut) then\n                 pos_x, pos_y = self:get_unit_screen_pos(ut)\n-                if layer_type == \"hp\" then\n+                if layer_type == \"hp\" and ut.max_hp > 0 then\n                     color = utils.get_health_color(ut.hp, ut.max_hp)\n                 elseif layer_type == \"type\" then\n                     color = utils.html_color_table[ut.type]\n                 elseif layer_type == \"player\" then\n                     color = utils.players_color_table[ut.playerId]\n+                elseif layer_type == \"shield\" and ut.shield > 0 then\n+                    color = utils.get_health_color(ut.shield, ut.max_shield)\n+                elseif layer_type == \"energy\" then\n+                    color = utils.get_health_color(ut.energy, 250)\n                 end\n-                img = self:draw_entity(img, pos_x, pos_y,\n-                                       ut.pixel_size_x, ut.pixel_size_y,\n-                                       color)\n+                if color then\n+                    img = self:draw_entity(img, pos_x, pos_y,\n+                                           ut.pixel_size_x, ut.pixel_size_y,\n+                                           color)\n+                end\n+            end\n+        end\n+    end\n+    return img\n+end\n+\n+function torchcraft:draw_value(img, pos_x, pos_y, size_x, size_y, value)\n+    local narrow_width_start = math.max(1,\n+                                        math.floor(pos_x - size_x / 2))\n+    local narrow_width_end = math.min(self.field_size[1],\n+                                      math.floor(pos_x + size_x / 2))\n+    local narrow_height_start = math.max(1,\n+                                         math.floor(pos_y - size_y / 2))\n+    local narrow_height_end = math.min(self.field_size[2],\n+                                       math.floor(pos_y + size_y / 2))\n+    -- Hack to fix crash were unit is on top left corner of FoV\n+    if narrow_width_end <= 0 then\n+        narrow_width_end = narrow_width_start\n+    end\n+    local rect = img:narrow(2, narrow_width_start,\n+                            narrow_width_end - narrow_width_start + 1)\n+    if narrow_height_end <= 0 then\n+        narrow_height_end = narrow_height_start\n+    end\n+    local rect = rect:narrow(1, narrow_height_start,\n+                             narrow_height_end - narrow_height_start + 1)\n+    rect:fill(value)\n+    return img\n+end\n+\n+function torchcraft:get_feature(feature, also_enemy, dtype)\n+--returns 2D imagelike tensor of feature\n+--type defaults to ByteTensor\n+\n+-- :TODO: Maybe make categorical features return a 3D tensor of one-hots\n+--        Or just render them to colors with draw value to increase spacing\n+\n+    local img\n+    if dtype == \"short\" then","path":"init.lua","position":112,"original_position":112,"commit_id":"bac0e88cf913fac1f4025b5c902c7832ee9b1303","original_commit_id":"bac0e88cf913fac1f4025b5c902c7832ee9b1303","user":{"login":"edran","id":3375046,"avatar_url":"https://avatars.githubusercontent.com/u/3375046?v=3","gravatar_id":"","url":"https://api.github.com/users/edran","html_url":"https://github.com/edran","followers_url":"https://api.github.com/users/edran/followers","following_url":"https://api.github.com/users/edran/following{/other_user}","gists_url":"https://api.github.com/users/edran/gists{/gist_id}","starred_url":"https://api.github.com/users/edran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edran/subscriptions","organizations_url":"https://api.github.com/users/edran/orgs","repos_url":"https://api.github.com/users/edran/repos","events_url":"https://api.github.com/users/edran/events{/privacy}","received_events_url":"https://api.github.com/users/edran/received_events","type":"User","site_admin":false},"body":"In Torch you can easily create different tensor types, so there is no need to have an additional argument specifying this. Also `img` is instantiated earlier and should be reused.","created_at":"2016-12-11T16:28:01Z","updated_at":"2016-12-11T16:36:17Z","html_url":"https://github.com/TorchCraft/TorchCraft/pull/12#discussion_r91859270","pull_request_url":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/comments/91859270"},"html":{"href":"https://github.com/TorchCraft/TorchCraft/pull/12#discussion_r91859270"},"pull_request":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12","id":97452774,"html_url":"https://github.com/TorchCraft/TorchCraft/pull/12","diff_url":"https://github.com/TorchCraft/TorchCraft/pull/12.diff","patch_url":"https://github.com/TorchCraft/TorchCraft/pull/12.patch","issue_url":"https://api.github.com/repos/TorchCraft/TorchCraft/issues/12","number":12,"state":"open","locked":false,"title":"New layers","user":{"login":"spencerduncan","id":647607,"avatar_url":"https://avatars.githubusercontent.com/u/647607?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerduncan","html_url":"https://github.com/spencerduncan","followers_url":"https://api.github.com/users/spencerduncan/followers","following_url":"https://api.github.com/users/spencerduncan/following{/other_user}","gists_url":"https://api.github.com/users/spencerduncan/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerduncan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerduncan/subscriptions","organizations_url":"https://api.github.com/users/spencerduncan/orgs","repos_url":"https://api.github.com/users/spencerduncan/repos","events_url":"https://api.github.com/users/spencerduncan/events{/privacy}","received_events_url":"https://api.github.com/users/spencerduncan/received_events","type":"User","site_admin":false},"body":"- Added max shields and resources as unit data. Resources was separated from HP so that resources of Refineries and such can be seen.\r\n- Added minerals, gas, energy and shields to get_layer and visual example.lua\r\n- Added function is_gas_geyser to utils.lua\r\n- Added functions get_feature and draw_values to init.lua\r\n    - get_feature is similar to get_layer, but outputs a 2D tensor instead of a 3D RGB tensor\r\n    - get_feature does not preform any scaling on values unlike get_layer, besides adding 1 to certain 0 indexed values\r\n    - draw_values is get_features version of draw_entities\r\n    - get_feature can handle any member variable of units, although some tweaking may be required for untested types\r\n    - added test script tensor_example.lua to examples. All cases used in this script have been tested.\r\n- Fixed a bug in get_layer where a unit being in the top-left corner of the screen could cause the script to crash\r\n- Changed default skip_frames in visual_example.lua to 30 to save disk space.\r\n- Added option --micro_game to visual_example.lua for testing of resource layers (mins/gas)\r\n- Added compiled BWEnv.exe and BWEnv.dll\r\n","created_at":"2016-12-11T08:59:45Z","updated_at":"2016-12-11T16:36:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"783efd494003403148854b8d64a55e032a406a51","assignee":{"login":"edran","id":3375046,"avatar_url":"https://avatars.githubusercontent.com/u/3375046?v=3","gravatar_id":"","url":"https://api.github.com/users/edran","html_url":"https://github.com/edran","followers_url":"https://api.github.com/users/edran/followers","following_url":"https://api.github.com/users/edran/following{/other_user}","gists_url":"https://api.github.com/users/edran/gists{/gist_id}","starred_url":"https://api.github.com/users/edran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edran/subscriptions","organizations_url":"https://api.github.com/users/edran/orgs","repos_url":"https://api.github.com/users/edran/repos","events_url":"https://api.github.com/users/edran/events{/privacy}","received_events_url":"https://api.github.com/users/edran/received_events","type":"User","site_admin":false},"assignees":[{"login":"edran","id":3375046,"avatar_url":"https://avatars.githubusercontent.com/u/3375046?v=3","gravatar_id":"","url":"https://api.github.com/users/edran","html_url":"https://github.com/edran","followers_url":"https://api.github.com/users/edran/followers","following_url":"https://api.github.com/users/edran/following{/other_user}","gists_url":"https://api.github.com/users/edran/gists{/gist_id}","starred_url":"https://api.github.com/users/edran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edran/subscriptions","organizations_url":"https://api.github.com/users/edran/orgs","repos_url":"https://api.github.com/users/edran/repos","events_url":"https://api.github.com/users/edran/events{/privacy}","received_events_url":"https://api.github.com/users/edran/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12/commits","review_comments_url":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12/comments","review_comment_url":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TorchCraft/TorchCraft/issues/12/comments","statuses_url":"https://api.github.com/repos/TorchCraft/TorchCraft/statuses/bac0e88cf913fac1f4025b5c902c7832ee9b1303","head":{"label":"spencerduncan:new_layers","ref":"new_layers","sha":"bac0e88cf913fac1f4025b5c902c7832ee9b1303","user":{"login":"spencerduncan","id":647607,"avatar_url":"https://avatars.githubusercontent.com/u/647607?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerduncan","html_url":"https://github.com/spencerduncan","followers_url":"https://api.github.com/users/spencerduncan/followers","following_url":"https://api.github.com/users/spencerduncan/following{/other_user}","gists_url":"https://api.github.com/users/spencerduncan/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerduncan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerduncan/subscriptions","organizations_url":"https://api.github.com/users/spencerduncan/orgs","repos_url":"https://api.github.com/users/spencerduncan/repos","events_url":"https://api.github.com/users/spencerduncan/events{/privacy}","received_events_url":"https://api.github.com/users/spencerduncan/received_events","type":"User","site_admin":false},"repo":{"id":75507325,"name":"TorchCraft","full_name":"spencerduncan/TorchCraft","owner":{"login":"spencerduncan","id":647607,"avatar_url":"https://avatars.githubusercontent.com/u/647607?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerduncan","html_url":"https://github.com/spencerduncan","followers_url":"https://api.github.com/users/spencerduncan/followers","following_url":"https://api.github.com/users/spencerduncan/following{/other_user}","gists_url":"https://api.github.com/users/spencerduncan/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerduncan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerduncan/subscriptions","organizations_url":"https://api.github.com/users/spencerduncan/orgs","repos_url":"https://api.github.com/users/spencerduncan/repos","events_url":"https://api.github.com/users/spencerduncan/events{/privacy}","received_events_url":"https://api.github.com/users/spencerduncan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spencerduncan/TorchCraft","description":"Connecting Torch to StarCraft","fork":true,"url":"https://api.github.com/repos/spencerduncan/TorchCraft","forks_url":"https://api.github.com/repos/spencerduncan/TorchCraft/forks","keys_url":"https://api.github.com/repos/spencerduncan/TorchCraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spencerduncan/TorchCraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spencerduncan/TorchCraft/teams","hooks_url":"https://api.github.com/repos/spencerduncan/TorchCraft/hooks","issue_events_url":"https://api.github.com/repos/spencerduncan/TorchCraft/issues/events{/number}","events_url":"https://api.github.com/repos/spencerduncan/TorchCraft/events","assignees_url":"https://api.github.com/repos/spencerduncan/TorchCraft/assignees{/user}","branches_url":"https://api.github.com/repos/spencerduncan/TorchCraft/branches{/branch}","tags_url":"https://api.github.com/repos/spencerduncan/TorchCraft/tags","blobs_url":"https://api.github.com/repos/spencerduncan/TorchCraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spencerduncan/TorchCraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spencerduncan/TorchCraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/spencerduncan/TorchCraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spencerduncan/TorchCraft/statuses/{sha}","languages_url":"https://api.github.com/repos/spencerduncan/TorchCraft/languages","stargazers_url":"https://api.github.com/repos/spencerduncan/TorchCraft/stargazers","contributors_url":"https://api.github.com/repos/spencerduncan/TorchCraft/contributors","subscribers_url":"https://api.github.com/repos/spencerduncan/TorchCraft/subscribers","subscription_url":"https://api.github.com/repos/spencerduncan/TorchCraft/subscription","commits_url":"https://api.github.com/repos/spencerduncan/TorchCraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/spencerduncan/TorchCraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/spencerduncan/TorchCraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/spencerduncan/TorchCraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/spencerduncan/TorchCraft/contents/{+path}","compare_url":"https://api.github.com/repos/spencerduncan/TorchCraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spencerduncan/TorchCraft/merges","archive_url":"https://api.github.com/repos/spencerduncan/TorchCraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spencerduncan/TorchCraft/downloads","issues_url":"https://api.github.com/repos/spencerduncan/TorchCraft/issues{/number}","pulls_url":"https://api.github.com/repos/spencerduncan/TorchCraft/pulls{/number}","milestones_url":"https://api.github.com/repos/spencerduncan/TorchCraft/milestones{/number}","notifications_url":"https://api.github.com/repos/spencerduncan/TorchCraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spencerduncan/TorchCraft/labels{/name}","releases_url":"https://api.github.com/repos/spencerduncan/TorchCraft/releases{/id}","deployments_url":"https://api.github.com/repos/spencerduncan/TorchCraft/deployments","created_at":"2016-12-03T23:52:32Z","updated_at":"2016-12-06T21:31:14Z","pushed_at":"2016-12-11T08:47:32Z","git_url":"git://github.com/spencerduncan/TorchCraft.git","ssh_url":"git@github.com:spencerduncan/TorchCraft.git","clone_url":"https://github.com/spencerduncan/TorchCraft.git","svn_url":"https://github.com/spencerduncan/TorchCraft","homepage":"","size":1241,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"TorchCraft:master","ref":"master","sha":"8a3b8880785ac0c69f478c30da7eacf3b7b8d411","user":{"login":"TorchCraft","id":20209289,"avatar_url":"https://avatars.githubusercontent.com/u/20209289?v=3","gravatar_id":"","url":"https://api.github.com/users/TorchCraft","html_url":"https://github.com/TorchCraft","followers_url":"https://api.github.com/users/TorchCraft/followers","following_url":"https://api.github.com/users/TorchCraft/following{/other_user}","gists_url":"https://api.github.com/users/TorchCraft/gists{/gist_id}","starred_url":"https://api.github.com/users/TorchCraft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TorchCraft/subscriptions","organizations_url":"https://api.github.com/users/TorchCraft/orgs","repos_url":"https://api.github.com/users/TorchCraft/repos","events_url":"https://api.github.com/users/TorchCraft/events{/privacy}","received_events_url":"https://api.github.com/users/TorchCraft/received_events","type":"Organization","site_admin":false},"repo":{"id":75440660,"name":"TorchCraft","full_name":"TorchCraft/TorchCraft","owner":{"login":"TorchCraft","id":20209289,"avatar_url":"https://avatars.githubusercontent.com/u/20209289?v=3","gravatar_id":"","url":"https://api.github.com/users/TorchCraft","html_url":"https://github.com/TorchCraft","followers_url":"https://api.github.com/users/TorchCraft/followers","following_url":"https://api.github.com/users/TorchCraft/following{/other_user}","gists_url":"https://api.github.com/users/TorchCraft/gists{/gist_id}","starred_url":"https://api.github.com/users/TorchCraft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TorchCraft/subscriptions","organizations_url":"https://api.github.com/users/TorchCraft/orgs","repos_url":"https://api.github.com/users/TorchCraft/repos","events_url":"https://api.github.com/users/TorchCraft/events{/privacy}","received_events_url":"https://api.github.com/users/TorchCraft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TorchCraft/TorchCraft","description":"Connecting Torch to StarCraft","fork":false,"url":"https://api.github.com/repos/TorchCraft/TorchCraft","forks_url":"https://api.github.com/repos/TorchCraft/TorchCraft/forks","keys_url":"https://api.github.com/repos/TorchCraft/TorchCraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TorchCraft/TorchCraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TorchCraft/TorchCraft/teams","hooks_url":"https://api.github.com/repos/TorchCraft/TorchCraft/hooks","issue_events_url":"https://api.github.com/repos/TorchCraft/TorchCraft/issues/events{/number}","events_url":"https://api.github.com/repos/TorchCraft/TorchCraft/events","assignees_url":"https://api.github.com/repos/TorchCraft/TorchCraft/assignees{/user}","branches_url":"https://api.github.com/repos/TorchCraft/TorchCraft/branches{/branch}","tags_url":"https://api.github.com/repos/TorchCraft/TorchCraft/tags","blobs_url":"https://api.github.com/repos/TorchCraft/TorchCraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TorchCraft/TorchCraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TorchCraft/TorchCraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/TorchCraft/TorchCraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TorchCraft/TorchCraft/statuses/{sha}","languages_url":"https://api.github.com/repos/TorchCraft/TorchCraft/languages","stargazers_url":"https://api.github.com/repos/TorchCraft/TorchCraft/stargazers","contributors_url":"https://api.github.com/repos/TorchCraft/TorchCraft/contributors","subscribers_url":"https://api.github.com/repos/TorchCraft/TorchCraft/subscribers","subscription_url":"https://api.github.com/repos/TorchCraft/TorchCraft/subscription","commits_url":"https://api.github.com/repos/TorchCraft/TorchCraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/TorchCraft/TorchCraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/TorchCraft/TorchCraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/TorchCraft/TorchCraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/TorchCraft/TorchCraft/contents/{+path}","compare_url":"https://api.github.com/repos/TorchCraft/TorchCraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TorchCraft/TorchCraft/merges","archive_url":"https://api.github.com/repos/TorchCraft/TorchCraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TorchCraft/TorchCraft/downloads","issues_url":"https://api.github.com/repos/TorchCraft/TorchCraft/issues{/number}","pulls_url":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls{/number}","milestones_url":"https://api.github.com/repos/TorchCraft/TorchCraft/milestones{/number}","notifications_url":"https://api.github.com/repos/TorchCraft/TorchCraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TorchCraft/TorchCraft/labels{/name}","releases_url":"https://api.github.com/repos/TorchCraft/TorchCraft/releases{/id}","deployments_url":"https://api.github.com/repos/TorchCraft/TorchCraft/deployments","created_at":"2016-12-03T00:04:58Z","updated_at":"2016-12-11T15:15:24Z","pushed_at":"2016-12-11T08:59:45Z","git_url":"git://github.com/TorchCraft/TorchCraft.git","ssh_url":"git@github.com:TorchCraft/TorchCraft.git","clone_url":"https://github.com/TorchCraft/TorchCraft.git","svn_url":"https://github.com/TorchCraft/TorchCraft","homepage":"","size":674,"stargazers_count":527,"watchers_count":527,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":67,"mirror_url":null,"open_issues_count":3,"forks":67,"open_issues":3,"watchers":527,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12"},"html":{"href":"https://github.com/TorchCraft/TorchCraft/pull/12"},"issue":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/issues/12"},"comments":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/TorchCraft/TorchCraft/statuses/bac0e88cf913fac1f4025b5c902c7832ee9b1303"}}}}
{"actor":{"display_login":"edran"}}