Coder Social home page Coder Social logo

core's People

Contributors

jkantr avatar mrracoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

core's Issues

createExpansion can return undefined townhallPosition

// main.js
import { createAgent, createEngine, createPlayer }  from '@node-sc2/core';
import { Difficulty, Race } from '@node-sc2/core/constants/enums';

const bot = createAgent({
    async onGameStart({ resources }) {
        const { units, actions, map } = resources.get();

         map.getEnemyMain(); //throws error 
    }
});

const engine = createEngine();

engine.connect().then(() => {
    return engine.runGame('RoyalBloodAIE', [
        createPlayer({ race: Race.RANDOM }, bot),
        createPlayer({ race: Race.RANDOM, difficulty: Difficulty.MEDIUM }),
    ]);
});

error looks like this:

TypeError: Cannot read properties of undefined (reading 'NaN')
    at Grid.getNodeAt (B:\projects\monorepo\typescript\sc2bot\node_modules\pathfinding\src\core\Grid.js:84:25)
    at AStarFinder.findPath (B:\projects\monorepo\typescript\sc2bot\node_modules\pathfinding\src\finders\AStarFinder.js:58:26)
    at Object.path (B:\projects\monorepo\typescript\sc2bot\node_modules\@node-sc2\core\resources\map.js:401:35)
    at B:\projects\monorepo\typescript\sc2bot\node_modules\@node-sc2\core\systems\map.js:325:39
    at Array.map (<anonymous>)
    at calculateExpansions (B:\projects\monorepo\typescript\sc2bot\node_modules\@node-sc2\core\systems\map.js:320:14)
    at Object.onGameStart (B:\projects\monorepo\typescript\sc2bot\node_modules\@node-sc2\core\systems\map.js:419:9)
    at B:\projects\monorepo\typescript\sc2bot\node_modules\@node-sc2\core\systems\create-system.js:107:65
    at Array.map (<anonymous>)
    at MapSystemWrapper (B:\projects\monorepo\typescript\sc2bot\node_modules\@node-sc2\core\systems\create-system.js:83:32)
    at B:\projects\monorepo\typescript\sc2bot\node_modules\@node-sc2\core\engine\create-engine.js:325:62
    at tryCatcher (B:\projects\monorepo\typescript\sc2bot\node_modules\bluebird\js\release\util.js:16:23)
    at Object.gotValue (B:\projects\monorepo\typescript\sc2bot\node_modules\bluebird\js\release\reduce.js:166:18)
    at Object.gotAccum (B:\projects\monorepo\typescript\sc2bot\node_modules\bluebird\js\release\reduce.js:155:25)
    at Object.tryCatcher (B:\projects\monorepo\typescript\sc2bot\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (B:\projects\monorepo\typescript\sc2bot\node_modules\bluebird\js\release\promise.js:547:31)
Map is not decomposable! If this is a 1v1 ladder map, please submit a bug report

Opens a black StarCraft 2 window

I'm just trying out the basic worker rush.

It opens the SC2 app (Version 5.0.2 (81433)) on my MacBook running Catalina (10.15.6) but unfortunately SC2 just renders a black window. SC2 works when I open it normally to play.

See:

Screen Shot 2020-08-27 at 12 09 33 PM

What am I missing? I've read all the docs. Thanks!

[jyan@jyan-mbp sc2]$ cat main.js
const { createAgent, createEngine, createPlayer } = require('@node-sc2/core');
const { Difficulty, Race } = require('@node-sc2/core/constants/enums');

const bot = createAgent({
    async onGameStart({ resources }) {
        const { units, actions, map } = resources.get();

        const workers = units.getWorkers();
        return actions.attackMove(workers, map.getEnemyMain().townhallPosition);
    }
});

const engine = createEngine();

engine.connect().then(() => {
    return engine.runGame('Blueshift LE', [
        createPlayer({ race: Race.RANDOM }, bot),
        createPlayer({ race: Race.RANDOM, difficulty: Difficulty.MEDIUM }),
    ]);
});
[jyan@jyan-mbp sc2]$ node -v
v14.8.0

Wine Support

Hi, thanks for the awesome project!
Is this supposed to work with Wine on Ubuntu assuming one has a working installation of SC2 that runs fine otherwise.
I know the protobuf API is Windows+Mac only but technically with Wine you are running the Windows version so I thought it would be fine.

Build command fails if x pos is zero

Apologies, I don't know which branch to submit a PR to. In resource/actions.js the code block around line 316, checking that a valid position has been passed, will end up throwing a BuildError if the value of x is zero.

image

Allow to use 'upgrade' to create an orbital

Currently the only way to morph an orbital command is to:

const { MORPH_ORBITALCOMMAND } = require('@node-sc2/core/constants/ability')
const { ability, build } = taskFunctions;

const test = createSystem({
    name: 'Test',
    type: 'build',
    buildOrder: [
        [13, build(SUPPLYDEPOT)],
        [13, build(BARRACKS)],
        [16, ability(MORPH_ORBITALCOMMAND)],
    ],

Probably it would be better to support the following:

const { ORBITALRELAY } = require('@node-sc2/core/constants/upgrade')
const { ability, build } = taskFunctions;

const test = createSystem({
    name: 'Test',
    type: 'build',
    buildOrder: [
        [13, build(SUPPLYDEPOT)],
        [13, build(BARRACKS)],
        [16, upgrade(ORBITALRELAY)],
    ],

unit.inject() do nothing

Currently unit.inject function without arguments do nothing, and the problem placed in egine/create-units.js in inject function, instead of this

const [idleHatch] = units.getById(UnitType.HATCH).filter(u => u.isIdle());

should be

const [idleHatch] = units.getByType(TownhallRace[Race.ZERG]).filter(u => u.isIdle());

But this solution causes another effect that any queen on run blank inject function will go to the main to inject it, though to inject nearest Hatchery has more sense.

something like this

const [idleHatch] = units.getClosest(this.pos, units.getByType(TownhallRace[Race.ZERG]), 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.