Code Monkey home page Code Monkey logo

screeps-typescript-starter's Introduction

screeps-starter

Starter kit for TypeScript-based Screeps AI codes.

This starter kit is a modified version of the original Screeps/TypeScript sample project by Marko Sulamägi.

Getting Started

After you create a spawn, this bot will create 4 creeps which will start to harvest the closest source. The bots harvest, then transfer energy back to Spawn. If a creep's lifespan has depleted enough, it will refill in Spawn.

Requirements

  • Node.js (v4.0.0+)
  • Gulp - npm install -g gulp
  • TypeScript - npm install -g typescript
  • Typings - npm install -g typings

Quick setup

First, create a copy of config.example.json and rename it to config.json.

$ cp config.example.json config.json

Then change the username and password properties with your Screeps credentials.

If you want to push your code to another branch, for example, if you have some sort of a staging branch where you test around in Simulation mode, we have left a branch option for you to easily change the target branch of the upload process. The default branch is set as the default.

WARNING: DO NOT commit this file into your repository!

Then run the following the command to install the required npm packages and TypeScript type definitions.

$ npm install

Running the compiler

# To compile your TypeScript files on the fly
$ npm start

# To deploy the code to Screeps
$ npm run deploy

Notes

The noImplicitAny compiler flag

TypeScript developers disagree about whether the noImplicitAny flag should be true or false. There is no correct answer and you can change the flag later. But your choice now can make a difference in larger projects so it merits discussion.

When the noImplicitAny flag is false (the default), the compiler silently defaults the type of a variable to any if it cannot infer the type based on how the variable is used.

When the noImplicitAny flag is true and the TypeScript compiler cannot infer the type, it still generates the JavaScript files. But it also reports an error. Many seasoned developers prefer this stricter setting because type checking catches more unintentional errors at compile time.

In this starter kit, the noImplicitAny compiler flag is set to false to make it easier for beginners. If you want a more stricter environment, you can change the noImplicitAny flag to true on the tsconfig.json file.

Source: https://angular.io/docs/ts/latest/guide/typescript-configuration.html

TSLint

TSLint checks your TypeScript code for readability, maintainability, and functionality errors, and can also enforce coding style standards.

After each successful compiling of the project, TSLint will parse the TypeScript source files and display a warning for any issues it will find.

This project provides TSLint rules through a tslint.json file, which extends the recommended set of rules from TSLint github repository: https://github.com/palantir/tslint/blob/next/src/configs/recommended.ts

We made some changes to those rules, which we considered necessary and/or relevant to a proper Screeps project:

  • set the forin rule to false, it was forcing for ( ... in ...) loops to check if object members were not coming from the class prototype.
  • set the interface-name rule to false, in order to allow interfaces that are not prefixed with I.
  • set the no-console rule to false, in order to allow using console.
  • in the variable-name rule, added allow-leading-underscore.

If you believe that some rules should not apply to a part of your code, you can use flags to let TSLint know about it: https://palantir.github.io/tslint/usage/rule-flags/

More info about TSLint: https://palantir.github.io/tslint/

Contributing

  1. Fork it
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Create a new Pull Request

Special thanks

Marko Sulamägi, for the original Screeps/TypeScript sample project.

screeps-typescript-starter's People

Contributors

resir014 avatar valerian avatar viezevingertjes avatar

Watchers

 avatar

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.