Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 2021-01-23 in all areas

  1. Hi, I want to introduce this patch properly, first of all, and it's hard to do in IRC. I think it was Stan who mentioned to me in another forum thread, that one of the things needing fixing in the engine, performance-wise, is the fixed point (64-bit) square root, which is found int Sqrt.cpp, named isqrt64(). This is a hand-coded routine, which I saw no immediate way of improving. But what I thought of is that I could somehow reduce calls to it by cacheing results. 99% if not 100% of the use of this routine is courtesy of FixedVector2/3D objects' Length() fn, to obtain integer sqare root of ( x*x + y*y [+z*z] ). Having done my share of programming and debugging in the past, I'm familiar with the fact that gazillions of calls to functions in most programs are kind of redundant, with the same variable read gazillions of times, or variables being "updated" a million times to the same value they were holding already. There's an entire movement out there of people who believe in general cacheing of all results from all functions; they want languages to begin adopting their philosophy... I'm not subscribed to it, but it merits a thought or two. In the case of FixedVectors, I wildly speculate that some of them have their length() function called many times, while other vectors might never hear a single call. (Case in point, point2d is implemented using FixedVector2D under the hood; but points don't have much of a length, do they?). Speaking of points and vectors, my next patch I'm thinking of is having non-class binary functions for point and vector math such that, A point minus a point = a vector The length of a vector is a length The length of a point is a compiler error A point plus or minus a vector = a point A vector plus a point = a point A vector minus a point is a compiler error A point plus a point results in a compiler error (or in a point-group ;-) Negative a vector is a (flipped) vector Negative a point is a compiler error It should prevent coding errors in the future; --might it dig up some from the past? I implemented all of this for my own engine 20 years ago. But getting back to this patch, my educated guess is that many vectors' lengths will never be looked at, while some may be looked at ad-nauseum. So I decided to experimentally try to (only when needed) compute the length of a vector, if not already cached; otherwise return the cached value when computing the length, cache the result, in case it is needed again before the vector is modified whenever the vector is modified, invalidate the cached length (but don't compute it again unless or until it is needed again) Thus, I added a member to the class, L, also of type "fixed". It holds the length of the vector when it does; otherwise it reads zero, meaning that the length is not current. Now, you might object to this saying "using a specific value to mean something is bad programming!", or "Isn't a zero length a valid length?!". Yes, all of that is true, however, vectors of zero length are hopefully not numerous, and if we were to assume the worst, namely ALL our vectors are zero length, the penalty, in this code, is to have as many calls to isqrt64() as we do at present; certainly not capital punishment; and actually I test X Y and Z for being zero before calling the length computation. That is, if I need the length, and see that the cached length is zero, I do look at X, Y and Z, and if all are zero I do nothing. Secondly, having an extra bool to indicate currency of the length variable is a bit performance-wasteful in the case of a flyweight class like this. In a big cyberpunk boilerplate class, I'd consider it, of course. Note that this is effectively a cacheing, or "proxy", and as such it suffers from a minor design gottcha: The function Length() looks like a pure function, and should be const as far as the outside world is concerned; but, under the hood, the update of the cached length often happens inside this const function. The right and only way to solve this issue, as is true of proxies in general, is to make L mutable. This is the true reason "mutable" exists; so let's use it. The new code, compiles, links, passes the 351 tests, and plays nice and smooth like a charm, --at least at the Very Easy setting I used to have momentary freezes of half a second every 5 minutes or so; now I don't notice them anymore; but I don't know if that's due to other changes happening on svn. To find out if peformance is improved, I need to profile. I followed the instructions in the Wiki for Profiler2 and tried it. It looks pretty. Now I will need to know how to count calls to isqrt64() and show them on the screen, or how to compare performance overall using a prerecorded game. However, either way, the testing needs to play back a game by user input commands; NOT by results; as it needs to test pathfinding and AI, which are probably stripped back when a game is being re-played like a movie. I will need help with all this. For now, if anyone's interested in trying it, looking at it, and/or profiling it, here's my latest svn diff: https://pastebin.com/nZt94JjJ (File also attached below.) Note that it seems nothing I've done is conflicting with any changes on svn; it looks like there's nothing to resolve yet. In the course of making these changes, I fixed a couple of other things about these classes: Dot() and CrossProduct() functions in FixedVector3D were not const X, Y (and Z) members were public, in both classes... Privatized them, then dded getX(), getY()... const...; and non-const Xref(), Yref(), etc. for external manipulators. This latter change caused changes in many other files, where the members were being read or written directly. That's why the diff is so big. Note that some people believe that making members of a class public should make the compiled code run faster than having access functions. That's the exact opposite of the truth: The elephant in the room nobody talks about is that C++ code is generally far faster than any hand-coded C equivalent, and there's good reasons for this (which Soustrup eloquently explained in a recent interview): The code optimizers of today have grown so smart that most assembler coders have a hard time competing with them; but optimizations thrive in an atmosphere friendly to assumptions; and some of the most useful assumptions in compiler optimization are about what can and cannot change where and when. C++ tries to limit access to the minimum necessary, limit scopes to the minimum necessary, hide whatever can be hidden... In such an environment, crazy optimizations become possible. But if you subversively defeat the best gifts C++ has to offer, such as by exposing class members, you kill many optimization possibilities at the same time. These classes should already help optimized code run faster on the basis of having closed off public access to its members alone; never mind the isqrt64() issue. Plus, I fixed alignment issues with padding. Compilers don't touch alignment with a ten-foot pole; this is coder-responsibility. (At least it was so 20 and 15 years ago; I may be behind the curve; if so, my apologies in advance.) EDIT: Speaking of elephants, 0ad elephants have gone on strike. I can't get them to do any building or repair work for me, anymore. In fact, even the hammer icon is gone. I don't believe it has anything to do with my changes... Ether they joined a union, or were accidentally given wooly mammoth AI, or both... diff.txt
    6 points
  2. Game Chat. Yellow player: Why are we paused????? Red player(Host): Blue player has gone offline for a moment. Yellow player: WTF! Why????? Red player(Host): He said he needed the toilet. Green player: He was obviously in need of a Kushite! Yellow player: LOL! Song: Salt'n'Peppa - Kush It!
    2 points
  3. What is AutoCiv This mod is an aggregation of features meant to enhance the 0 A.D. game experience. I usually implement these extra features as they come up with no general plan in mind. Download (how to install section below) autociv.pyromod autociv.zip Feature list General Readme: press Shift + F4 to open Player mute Player reminder (show a written note when a certain player joins) *** Link opener (opens URL links from the chat) Help command: type /help to see all available commands Console with autocomplete (Ctrl + C + L) Lobby Resize bars Host name mark Remember playerlist state Better performance when reloading lobby Shortcuts to create host, navigate gamelist Game setup Auto-assign civilization with chat (only works if host has the mod) Custom population limit Custom starting resources Custom map size Countdown to start the game Maps Skirmish Volcano island (8) In Game Hotkeys for (see hotkeys with hotkey viewer) Buildings placement Multiple buildings per hotkey (optional, user.cfg) How to use: Copy the hotkey you want and remove the "hotkey." prefix, next replace the hotkey key for the buildings you want to cycle and separate them by a space. Buildings selection Units selection Formations (selected units) Stances (selected units) Auto-train (selected buildings) Minimap expand Custom selection filters by: health rank class group Pause game overlay now shows only in the top area Stats overlay Settings Max corpses visible Download options Download and install from one of the two files from the start of this same page. Download and install manually the github repository (instalation file on the releases section) https://github.com/nanihadesuka/autociv Use 0 A.D. mod downloader (not always newest version) https://0ad.mod.io/autociv Instructions to install MacOS (thanks @HMS-Surprise) Linux/Windows: Open the downloaded file with (both ways should work): pyromod file: Double click the file (should autoinstall the mod for you and send you to the mods page inside 0ad) Right click → Open with → 0 A.D (or pyrogenesis.exe) ** NOTICE: in Alpha 25 the pyromod installation will trigger an error message: to fix just disable autociv, restart the game and enable autociv again. zip file: Copy folder inside the zip file into your mods folder Mod compatibility(s) The mod is compatible with: 0 A.D 0.0.27 Probable to work alongside other community mods as balanced maps spec mod (monitor) custom_rating boonGUI Should work with all mods that don't have extensive code changes. More stuff & goodies For more info just read the whole thread where I post new features. Questions & feedback You don't understand how it works? Feeling confused? Just wanna comment? Ask and post. Source code public repository https://github.com/nanihadesuka/autociv
    1 point
  4. When capturing was introduced I didn't particularly like it. As it came up recently, as in make sieges not capture-able I tried to recall why this was so. One aspect is the capture-delete meta. This could be fixed by buildings needing being demolished as they need be built and could award some of the resources back as compensation. The other was when capturing got introduced I felt the unit behaviour quite a bit annoying. So I changed the code that capturing needs to be explicitly ordered for it to happen. Turns out it feels better but not by as much as I expected. Probably having to adjust to the new behaviour when capturing got introduced made it feel worse than it actually was. So that others may try how it would feel I packaged the changes into a minimalistic mod for A23. You have to add a definition for hotkey.session.capture to your local.cfg (~/.config/0ad/config/local.cfg on Linux) if you still want to be able to capture targets after loading the mod. capture-0.23.0.pyromod
    1 point
  5. When I rotate the camera lens, the shadow on the roof of the Municipal Center will flicker, and the color of the shadow will change from dark to light.
    1 point
  6. Incredible man! These are the icons the game needs for sure.
    1 point
  7. This is a classic example of a shadow bias problem. It shouldn't be particularly new, can you verify that this only happens following a recent commit? Edit: Vladislav confirms an issue -> D3457
    1 point
  8. @vladislavbelov @Stan` Please help me. commands.txt
    1 point
  9. How do I fix this?
    1 point
  10. 1 point
  11. 1 point
  12. Had some fun the phase icons using my new letters. phase_sources.7z
    1 point
  13. https://trac.wildfiregames.com/changeset/24753
    1 point
  14. Starting new game with 0ad (svn-revision 23824) and only one mod: milleniumad it works ...
    1 point
×
×
  • Create New...