• Content count

  • Joined

  • Last visited

Community Reputation

967 Good

About Toolmaker

  • Rank
  1. Anyone tried Screeps, the MMO for programmers?

    So, anyone still playing but me? I scrolled around the map to find any of you but couldn't find your room and looking by the ranking it seems your AIs have been obliterated and never respawned.    Over the past week I kinda came to the conclusion that I tried to solve too many issues at the same time in code. I wanted to automatically build miners, balance trucks, find the most ideal energy distribution scheme, build creeps based upon the amount of energy in store combined with production statistics and threat level. So I ended up with a big ball of clutter that tried to do everything and failed at it all.   So I took a tinsy detour and refactored the whole thing into a message based system where each message would pretty much just do 1 thing(heh, turns out SRP isn't such a bad idea after all) and the AI executes message by message, measures the amount of time left and if CPU is about to run out it will cease message processing. Much more robust and turns out, much easier to develop as well. Most things are still done manually: if I want to mine a source I have to issue a command and the AI will then spawn a builder and trucks for it but with these basic commands I can start building more complex ones and then a decision making module that will trigger.
  2. How many of you write self-documenting code?

    I'm not sure why most programmers seem to be doing this but it is a wide-spread phenoma. Robert C. Martin goes into the subject in 'Clean Code' (which in my opinion should be standarized reading material for EVERY and ALL programmers which they should re-read every one or two years).   I've ran into these issues at my current job more than once and over there it is a cultural thing. Many of my colleagues find that writing three letter variables is less work(because hey, intellisense isn't there to autocomplete it the first time you write it out) and prefer to write everything according to the hungarian misnotation. The result is a mix of incredibly unreadable code, mixed in with prefixes such as int, dbl, bln on variables are all different types(in many cases not even the type declared in the variable name) with sometimes a line of comment above each regular line of code, such as: // loop over all the items in the list for (var objItem in lstItems) { // do something with objItem DoSomething(objItem); // Transfer into the list of processed items lstProcessedItems.Add(objItem); } What I've seen in my work is that the more people stick to basic guidelines such as the Single Responsiblity Principle(SRP) and the like the more likely they are to also write self-documenting code. The more you mix different aspects together the less easy it becomes to write code that documents itself because boundaries become fuzzy and naming isn't as exact and simple as when an object or a method does only one thing.   I do agree with single letter variables are a big no-no unless you're using Linq(Where(o => o != null) is as readable as Where(theObject => theObject != null)), loop-variables to signify index or loop values.   But in the end: since every book or tutorial seems to abbreviate things it is what you learn first. And first habits are easily becoming engrained as the norm.
  3. Anyone tried Screeps, the MMO for programmers?

    There are solutions around the debugging which can mostly be found in the form of unit tests. You use run them using node.js combined with a unit testing framework. Write a bunch of mocks for game functionality you want to test and viola. It will of course be more work to build stuff but at least you know it checks out when you put it in production.   I think once you have a basic framework covering production, construction and planning the game becomes more about strategy.
  4. Anyone tried Screeps, the MMO for programmers?

    I think alliances are inevitable in the game, you simply can't take on everyone at the same time as you'd probably have to defend from various attackers simultaneously. Of course, that might be a pretty interesting game to watch I suppose.   So, what strategies are being taken when it comes to building creeps? I currently just take the amount of available energy into account and build new creeps based on that. Still using mostly statics bodies.
  5. Anyone tried Screeps, the MMO for programmers?

    I use dedicated creeps too. Like most, I have miners that mine and trucks that pick up any energy and deliver them to builders or structures. Trucks have a dedicated pickup location but dynamic dropoffs. For dropoffs I use spatial map in which consumers report their demands along with a priority. Structures always get precedent over builders so that I can keep spawning before building things. It took a while to get working and tweaked properly but it works pretty nicely.   Currently working on a spawn system that takes average energy production and number of extensions into account and also plans on which creeps to replace with which. I've had a few hickups where all creeps died quickly after eachother, clogged up the build queue with the wrong creeps and ended up in a coma. It happens less and though, which is kinda nice.   After that, I think I'll implement soldier logic to hunt down source keepers and construction logic to build ramparts after which I think I got all the basics in for an AI that can sustain a room by itself and then start on expanding/combat.
  6. Anyone tried Screeps, the MMO for programmers?

    The initial investment is rather steep if you ask me because you do need to churn out a basic AI that is capable of doing collecting resources, defending the room, constructing various structures, distributing energy across the spawns, extensions and workers. However, once you have the basic behaviors in it is a matter of fine tuning and giving orders.   It takes time to take control of new rooms, especially rooms taken by other players. But even if rooms were already empty, it takes time to construct buildings, upgrade the controller and ensure its defendable. So all in all, once you have the basic decision making in it should be pretty much capable of taking care of itself unattended. But that still requires quite a lot of time on short notice. I found that getting the hang of Javascript took me a while and all the code I wrote along the way needs some pretty major refactoring in order to get it into a better shape.
  7. Anyone tried Screeps, the MMO for programmers?

      I hope you get well soon!
  8. Anyone tried Screeps, the MMO for programmers?

    Done. You have received my final Early Access Preview code. Let me know which room you're all in, I'd love to see how others are better than me :P.
  9. Anyone tried Screeps, the MMO for programmers?

    I'm playing under the same name as my GDNet account: Toolmaker. I'm located in room W13S11, which is in the bottom left corner of the map. At the moment my AI doesn't do very much, haven't had a lot of free time.   I did completely revamp the system to keep track of energy needs over the weekend. Re-factored it into a spatial map and ensure that extensions would be properly served, which isn't the case in the current implementation. Still need to find some time to actually test it and put it in production so I can finally construct creeps with more body parts and thus create soldiers to mine the two guarded sources in my room. And I really need to write code to construct more defenses in my room, such as ramparts blocking the exits.   Dragonsoulj: I'll PM you one access code.   Got one more left(actually had three instead of the advertised two).
  10. Anyone tried Screeps, the MMO for programmers?

    I don't think it is possible to call code from outside the sandbox. I've seen a few error stacktraces that mentions lodash's runInContext(), so I strongly doubt that you can even access code or memory from outside said context.   That being said, its possible to add any library you'd like to include as long as it doesn't rely on external bindings. There are limitations, such as the game doesn't appear to have any folders. My source on disk is divided up into folders but after uploading with Grunt it is all flattened which can be tricky in larger projects.   I still have an Early Access code available, gave one out to slicer4ever via a PM.
  11. Back in november I stumbled upon the crowdfunding of Screeps, a massive multiplayer online game designed for programmers. It is a strategy game where you do not play but program an AI to play for you. I decided to throw in some money because it made me excited and as a result I've been toying around for the past several weeks in the early access preview.   And I must admit that I quite like it. It is challenging: the game provides the basic game mechanics and functionality such as path finding and examing the playing field and manipulating it and the rest is up to the programmer. Basic things, like building a unit that collects energy or one that picks up energy from a creep that is mining for energy and bringing it to unit that needs it are quite simple. But once you have more than a few creeps things start needing coordination and it gets more complex.   I think this might also be a very good way to learn game programming: the game has a tick based architecture and in order to keeps things efficient you need to figure out a way to keep track of resources, overall state units and rooms. In the few sessions I've spent on the game I had to dive into some algorithms(implemented a breadth-search for finding suitable construction area), data structures(currently researching spatial hashing to group together local energy needs) and working out how to keep the game running efficiently.   I also happen to have two additional tokens for use in the early access preview. If anyone is interested I'd to happy to share them on first-come basis. However, please think about if you're actually gonna play or just want to check it out and abandon it. There are quite a few players who's AI seem starved, unresponsive and stuck without being updated and it would be a shame if my tokens would be used in such a fashion too. If you do want to try it out for a bit, it has a built-in code editor and a partial simulation that runs in the browser under simulation, where also the tutorial can be found.   If anyone's playing: I'd love to hear other experiences.
  12. I recently procured an HTC Desire Z and I was amazed by the sheer amount of applications available for it and decided I wanted to do some development as well. I got quite a nice idea and want to do a little hands-on approach by developing a little app that controls iTunes over the network. Nothing new or innovation, but it's a good start to get my hands dirty with some development including networking. But, I've done some network coding in the past, but I'm not entirely sure how to approach this, as I require a protocol to be designed. And that's exactly where I could use some help, because my past attempts at doing network level stuff usually turned into a horrible pile or terrible code. The protocol for this little app should be bi-directional: Commands from the Android app to the server, and the server returning bits of information about play lists, artists, albums, player status, progress in song and volume level. What would be the best way to approach this? I thought about using XML since that's easily parseable(since I'll be using tons of text anyway) and allows easy transmitting of text. What things should I keep in mind here?
  13. Home automation

    I quite recently procured myself an HTC Desire Z phone and I was amazed by the sheer amount of awesome applications found in the market place. After messing about for a bit, I obtained iRemote for iTunes and VLC remote, which nicely lets me control iTunes and VLC through my phone. Which is awesome, since most of the time, my laptop is set up to play music while I am running through the house doing things. But, this got me thinking, this can be so much more fun. I have most of the things in my house hooked up to a remote controlled switch box, so I can turn my lights off/on with a remote. I technically could mold all these into 1 single machine and control it all through my phone. Pop a laptop in my TV stand, hook up TV and audio to it, install iTunes and hook up my lights remote to it as well. That way, I can just open an application and change lights, start a movie, etc. Who here uses one of these systems, and what do you use / what did it cost? I could technically roll my own, which I *might* do because there are plenty of open-source products to control VLC, iTunes, etc and I could merge them into a single application.
  14. extended ascii (, ,...)

    Quote:Original post by m_power_hax Quote:Original post by Evil Steve Quote:Original post by m_power_hax Nope, didn't work. I was able to remove characters (making the grid be 5x5 as an example). But making the grid (16x16) and making the loops go from 32 to 256 didnt change anything.What if you save the texture to a BMP file? Does it look correct (I.e. does it have the new characters on it)? I don't know how to save the texture. Consider a career change. You seem to lack the understand and drive to research things in order to be a programmer.
  15. I'm trying to get an MFC checkbox to draw itself with a transparent background, and at this point, I'm going nuts because nothing seems to work. Initially, I figured I'd handle the WM_ERASEBKGND, BitBlt() to an in-memory bitmap and when re-painting paint the bitmap and voila. Alas, this didn't work and only made the control flicker when I move my mouse over, but still draws it's control coloured background. Next up was catching the WM_CTLCOLOR in the dialog. Same result though, still in it's original control background colour. I even tried the handle WM_CTLCOLOR_REFLECT in a derived control but that still doesn't work. I'm sort of lost here, since these are the solutions provided on the internet. Any ideas here? Toolmaker