Posts for Bisqwit


Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Derakon wrote:
It sounds like your bot would have to spend less time on move decision and more time on move simulation, right? That is, the search space is smaller, but each option requires longer to judge if it is acceptable.
Yes. In any case, almost all time goes to the simulation regardless; the move decision part is just a for loop that takes a dozen microseconds at most.
Post subject: Idea: Lunar Ball - Zero Friction mode
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Lunar Ball has this interesting feature, that on the configuration screen, its friction setting can be arbitrarily selected from integer values 0 to 255. The default value is 32. The value 0 in particular is very interesting: It literally means "no friction whatsoever". [img_right]http://bisqwit.iki.fi/kala/snap/newtoncradle.gif[/img_right] A pool game played in completely frictionless setup is a very different game from a normal pool game. In a frictionless game, it is more than possible, that a careless shot makes the game completely unwinnable. Indeed, it is easy to demonstrate such a shot that will leave the game into an infinite loop, much resembling the effect that happens in the popular gadget, "Newton's cradle". In such a loop, there is no choice but to reset the console, terminating the game. From a computer player's viewpoint, this means that the searching space for valid moves is drastically smaller than it is for a regular game: most shots produce either an infinite loop, or they result in the eventual demise of the cue ball. Due to the law of conservation of energy, so called "preparation shots" simply cannot be done, either. This also means that unless you "suicide" once in a while (intentionally pocket the cue ball), you get a "PERFECT" message in all boards, and that the scores skyrocket. Also, the timeout for shots should be set considerably longer than in a default-friction game, because the balls can be gliding for a long time before they eventually find a pocket. The question is... Would this be interesting to see?
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Kuwaga wrote:
Bisqwit wrote:
2 |6% |fox nes |5 |
This one cracks me up. xD
Heh. Surprisingly high clickthrough ratio! Conclusion: Typoking people are also curious.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Flygon wrote:
I'm officially the 2nd most popular TASVideos member.
After batman? Or after TAS?
Post subject: Google knows something too
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
More from Google:
As of February 2nd, 2010

Links to your site
              Page                Links (11,455)
--------------------------------------------------------
http://tasvideos.org/             3,510
Adelikat.html                     289
SuperMarioWorldTricks.html        171
SuperMarioBrosTricks.html         150
WhyAndHow.html                    111
Search.html?key=Metroid&subs=1    88
1438M.html                        57
forum/t/8739                      50
2494S.html                        49
FAQ.html                          46
forum/viewtopic.php?t=2050        45
2087S.html                        43
871M.html                         35
forum/viewtopic.php?p=159794      33
1324M.html                        31
Flygon.html                       31
711M.html                         30
723M.html                         28
1035M.html                        27
31S.html                          26
1053M.html                        24
1796S.html                        24
1850S.html                        24
576M.html                         24
Upthorn.html                      24
1115M.html                        23
Movies-SNES.html                  21
| All searches, All domains, January 2010

|Impressions : Your site appeared in these searches |        Clickthrough : Users clicked on your         
|                                                   |               site in these searches            |    
| # | % |                Query                |Pos. | # | % |              Query                 |Pos.|
|---+---+-------------------------------------+---+ |---+---|------------------------------------+----|
|1  |24%|tas                                  |7  | |1  |32%|tasvideos                           |1   |
|2  |6% |fox nes                              |5  | |2  |9% |tas videos                          |1   |
|3  |4% |411 usa                              |7  | |3  |7% |tas                                 |2   |
|4  |4% |tasvideos                            |1  | |4  |7% |tasvideo                            |1   |
|5  |3% |bomberman 4                          |10 | |5  |7% |tas video                           |1   |
|6  |3% |usa 411                              |8  | |6  |4% |tasvideos.org                       |1   |
|7  |3% |time attack                          |8  | |7  |4% |tool assisted speedrun              |1   |
|8  |2% |speedrun                             |10 | |8  |3% |tas speedrun                        |1   |
|9  |2% |batman                               |17 | |9  |3% |tool assisted speed run             |2   |
|10 |2% |speed run                            |8  | |10 |1% |bisqwit                             |1   |
|11 |2% |speed runs                           |6  | |11 |1% |tool assisted                       |1   |
|12 |1% |new movies                           |6  | |12 |<1%|nesvideos                           |1   |
|13 |1% |flygon                               |12 | |13 |<1%|nes videos                          |1   |
|14 |1% |fceux                                |9  | |14 |<1%|tasvid                              |1   |
|15 |1% |speedruns                            |7  | |15 |<1%|solomon's key 2 walkthrough         |1   |
|16 |1% |tas videos                           |1  | |16 |<1%|tas speed run                       |1   |
|17 |1% |olympus usa                          |6  | |17 |<1%|nes tas                             |1   |
|18 |1% |tasvideo                             |1  | |18 |<1%|tool-assisted                       |1   |
|19 |1% |genesis                              |15 | |19 |<1%|tas tool                            |1   |
|20 |1% |tas video                            |1  | |20 |<1%|super mario bros tricks             |1   |
|21 |<1%|tool assisted speedrun               |2  | |21 |<1%|tas speedruns                       |1   |
|22 |<1%|speed demos                          |8  | |22 |<1%|super mario world tricks            |1   |
|23 |<1%|131.com movies                       |8  | |23 |<1%|tool assisted speed runs            |1   |
|24 |<1%|bubble game                          |11 | |24 |<1%|tool assisted speedruns             |1   |
|25 |<1%|456 movies                           |4  | |25 |<1%|tas-videos                          |1   |
|26 |<1%|movies 278                           |10 | |26 |<1%|tas runs                            |1   |
|27 |<1%|rondo                                |15 | |27 |<1%|tas speed runs                      |1   |
|28 |<1%|movie statistics                     |9  | |28 |<1%|tas nes                             |1   |
|29 |<1%|joker                                |19 | |29 |<1%|tool-assisted speedrun              |2   |
|30 |<1%|chrono trigger endings               |10 | |30 |<1%|nes movies                          |1   |
|31 |<1%|dasrik                               |7  | |31 |<1%|nes speed runs                      |1   |
|32 |<1%|tasvideos.org                        |1  | |32 |<1%|tas vid                             |1   |
|33 |<1%|jpn                                  |14 | |33 |<1%|tool assisted videos                |1   |
|34 |<1%|tool assisted speed run              |2  | |34 |<1%|avisplitter.ax                      |1   |
|35 |<1%|pizza pop                            |11 | |35 |<1%|super mario tricks                  |1   |
|36 |<1%|alex                                 |16 | |36 |<1%|tas vidéo                           |1   |
|37 |<1%|megaman                              |37 | |37 |<1%|tas games                           |1   |
|38 |<1%|acmlm                                |8  | |38 |<1%|tas speed                           |2   |
|39 |<1%|ventuz                               |8  | |39 |<1%|super mario brothers tricks         |1   |
|40 |<1%|donkey kong country 3 rom            |5  | |40 |<1%|tas tool assisted speedrun          |1   |
|41 |<1%|super mario bros.org                 |10 | |41 |<1%|tas vids                            |1   |
|42 |<1%|console game                         |9  | |42 |<1%|official tasvideos                  |1   |
|43 |<1%|time attack game                     |8  | |43 |<1%|http://tasvideos.org/1438m.html     |1   |
|44 |<1%|mailto                               |12 | |44 |<1%|super metroid tricks                |1   |
|45 |<1%|131 movies                           |6  | |45 |<1%|tas tool assisted                   |1   |
|46 |<1%|donkey kong country 2 rom            |8  | |46 |<1%|tasvidoes                           |1   |
|47 |<1%|tas speedrun                         |1  | |47 |<1%|mario tricks                        |1   |
|48 |<1%|international superstar soccer deluxe|8  | |48 |<1%|tasvids                             |1   |
|49 |<1%|1075 the game                        |9  | |49 |<1%|nes time attack                     |1   |
|50 |<1%|super mario brothers 1               |6  | |50 |<1%|tas game                            |1   |
|51 |<1%|castlevania                          |19 | |51 |<1%|speed runs                          |4   |
|52 |<1%|x4                                   |15 | |52 |<1%|faxanadu password generator         |1   |
|53 |<1%|super demo world                     |11 | |53 |<1%|how to tas                          |1   |
|54 |<1%|video game speed runs                |4  | |54 |<1%|movies 1010                         |1   |
|55 |<1%|batman movies                        |24 | |55 |<1%|simon's quest password generator    |1   |
|56 |<1%|nes power                            |10 | |56 |<1%|zelda outlands walkthrough          |1   |
|57 |<1%|decap attack                         |11 | |57 |<1%|tool tas                            |4   |
|58 |<1%|bisqwit                              |1  | |58 |<1%|kid chameleon levels                |1   |
|59 |<1%|super mario bros tricks              |2  | |59 |<1%|nes superplay                       |1   |
|60 |<1%|super mario wii tricks               |8  | |60 |<1%|ocarina of time backflip            |1   |
|61 |<1%|"mr. gimmick" nes download           |6  | |61 |<1%|ocarina of time tricks              |1   |
|62 |<1%|maria                                |19 | |62 |<1%|reverse bottle adventure            |1   |
|63 |<1%|bubbles game                         |11 | |63 |<1%|super mario world flying controls   |1   |
|64 |<1%|89 movies                            |9  | |64 |<1%|tasmovies                           |1   |
|65 |<1%|average movie length                 |7  | |65 |<1%|time attack videos                  |1   |
|66 |<1%|tool assisted                        |1  | |66 |<1%|tools assisted speed run            |1   |
|67 |<1%|movies 209                           |6  | |67 |<1%|www.tasvideos.org                   |1   |
|68 |<1%|street fighter 2010 rom              |7  | |68 |<1%|speedrun                            |8   |
|69 |<1%|video game movies                    |10 | |69 |<1%|castlevania 2 password generator    |1   |
|70 |<1%|forum ranks                          |15 | |70 |<1%|nes video                           |1   |
|71 |<1%|super mario kart rom                 |7  | |71 |<1%|solomons key 2 walkthrough          |1   |
|72 |<1%|yie air kung fu                      |10 | |72 |<1%|tas movie                           |1   |
|73 |<1%|mega man                             |19 | |73 |<1%|tas vidéos                          |1   |
|74 |<1%|super mario bros                     |41 | |74 |<1%|tasvideos forums                    |1   |
|75 |<1%|super mario bros .org                |8  | |75 |<1%|tasvidéo                            |1   |
|76 |<1%|knuckles the hedgehog                |16 | |76 |<1%|tool assisted video                 |1   |
|77 |<1%|smsking                              |11 | |77 |<1%|tasvideo.org                        |2   |
|78 |<1%|chan4                                |10 | |78 |<1%|how to make a tool assisted speedrun|1   |
|79 |<1%|castlevania circle of the moon rom   |9  | |79 |<1%|http://tasvideos.org/               |1   |
|80 |<1%|gba                                  |24 | |80 |<1%|mario bros tricks                   |1   |
|81 |<1%|gens emulator                        |9  | |81 |<1%|nes speed run                       |1   |
|82 |<1%|one player games                     |7  | |82 |<1%|nes speedrun                        |1   |
|83 |<1%|mega usa                             |9  | |83 |<1%|super mario world wall jump         |1   |
|84 |<1%|castlevania gba                      |14 | |84 |<1%|tas videos.org                      |1   |
|85 |<1%|aroduc                               |8  | |85 |<1%|tasvideos.org/                      |1   |
|86 |<1%|mighty final fight                   |9  | |86 |<1%|tool assisted tas                   |1   |
|87 |<1%|convert f c                          |8  | |87 |<1%|super mario world flying            |2   |
|88 |<1%|diamonds usa                         |9  | |88 |<1%|super metroid glitches              |3   |
|89 |<1%|nes tetris                           |9  | |89 |<1%|speed run                           |8   |
|90 |<1%|superbowl 11                         |9  | |90 |<1%|speed tas                           |1   |
|91 |<1%|nes zelda map                        |12 | |91 |<1%|super mario bros 3 .smc             |1   |
|92 |<1%|avisplitter.ax                       |3  | |92 |<1%|super mario world cape flying       |1   |
|93 |<1%|super mario bros glitches            |5  | |93 |<1%|tasvideos forum                     |1   |
|94 |<1%|nespower                             |10 | |94 |<1%|the legend of zelda outlands        |1   |
|95 |<1%|snes                                 |27 | |95 |<1%|super mario land glitches           |2   |
|96 |<1%|kid niki 3                           |7  | |96 |<1%|speed run tas                       |1   |
|97 |<1%|sms king                             |7  | |97 |<1%|super demo world walkthrough        |1   |
|98 |<1%|dr warp                              |10 | |98 |<1%|super mario bros wall jump          |1   |
|99 |<1%|super mario tricks                   |3  | |99 |<1%|super metroid legacy rom            |1   |
|100|<1%|solomon's key 2 walkthrough          |1  | |100|<1%|tas video game                      |1   |
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
NrgSpoon wrote:
My only guess is that the bug on stage 40 could have something to do with the sprite limit per line? Since it has all the balls lined up horizontally, plus all those obstacles added in. Possibly a lag factor involved in the checks.
Noting the fact that the music was also affected, and the moment it was, I think it was something like that the number of collisions was too high and it overflowed some buffer. This demands investigation! Dejavu. Hmmm… http://bisqwit.iki.fi/jutut/lunarball.lst -- disassembly http://bisqwit.iki.fi/jutut/lunarball.map -- ram map If someone wants to do research.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Voted not, this movie does not color a dinosaur, which I couldn't care less about.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
mklip2001 wrote:
Very nice! By the way, what the heck happened with stage 40? Why did the balls disappear in that spot?
That's what I would like to know, too! Somehow, the game generated spontaneously a few black holes to the board. EDIT 2010-02-02: Oh, I now watched it with sounds. Apparently the music was affected too!
mklip2001 wrote:
Also, you got a Perfect on that stage with the single ball (I think it's stage 27). It's quite impressive, but is it faster to beat that stage in 2 shots to avoid getting the Perfect bonus?
It has been almost two years since that stage was played, but I remember that this was indeed the solution the bot ended up with ― and it did test shooting a dummy shot first. It did offer a number of ways of pocketing a few balls instead of all of them, but I think I was quite happy of keeping this shot in the movie (it's not that common a sight, don't you think!) instead of exploring a way to pocket balls in more rounds.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
New WIP! http://dehacked.2y.net/microstorage.php/info/1577783193/lunarball.fcm 40 stages completed, going at 41st. ___________
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Nach wrote:
Bisqwit wrote:
I can't even think of those posts looking funny 1 month after the movie has been published.
Well, now it's some years later, and I still find it funny. It seems your opinion, which you mistakenly believe you're entitled to, is in fact - Wrong!
As memory goes, even after reading those posts again, I have no idea what was going on, and I now don't even see the alleged funny.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
It's a pity indeed in that not even does www.longplays.net have Atari 2600 videos.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
L-Spiro wrote:
But the fact that you are taking it above and beyond that means my quiz was more of a success than I had planned.
I like your attitude, but this was just a case of the Take a Third Option mentality…
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
L-Spiro wrote:
I should say that the correct answer is only correct between 32-bit and 64-bit machines.
Sorry for insisting, but even given what you wrote, are there no platforms where "long" size may be 64-bit but pointer size is 32-bit? I would imagine that many 64-bit platforms have no need for 64-bit pointers...
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
So the "tiny consideration" was regarding the relative placement of the void* and the long, in that on 64-bit Windows, void* and long are not the same size because "long" is still 32 bits? I see. How about platforms where long is larger than void*? Such as 16-bit Borland C++. Your "best" selection would lead into the following memory layoutexcept that BC aligns at 2, never at 4:
Addr Size Data
0000 8    64-bit object (int64)
0008 2    16-bit object (void*)
000A 2    <padding>
000C 4    32-bit object (long)
0010 <end>
You yourself said that you are programming for various non-PC platforms, such as the Nintendo DS, so you cannot exclude 16-bit platforms, since those are used often for microcontrollers.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Status: Board 40 is about to be completed within a day or three. Apparently, turns out that the bot figured out a way to create stable black holes. I'll post a WIP after this board is completed.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
L-Spiro wrote:
As such, the answer for #7 is also based on simplicity, and I am at least willing to tell you that it is similar to #3 and #4. If I give any more hints than that then it may become too simple to solve, so I have to stop there.
Well, this is pointless, but here goes. #7: for ( int I = iTotal; I-- > 0; ) { // Do something. } #1: Dost thou mean: CallFunction(fX * 0.0625, fY * 0.0625)? Falls to the category "redundant". See, here's what GCC produces for the original code at -O1: _Z1gv: movsd .LC0(%rip), %xmm1 movapd %xmm1, %xmm0 mulsd fY(%rip), %xmm1 mulsd fX(%rip), %xmm0 jmp CallFunction <...> .LC0: .long 0, 1068498944 At most, this is a pessimization, because it hides the purpose of the code. Remember, the source code is also a documentation ― first and moremostly, it should document the intended purpose of the code, and only next, convey the practical means used to accomplish the purpose, in the simplest and easiest to maintain manner possible. At least that is the view I hold firmly and dearly. If you have got SSE2, you can also go with: #include <emmintrin.h> <...> __m128d tmp2 = _mm_mul_pd(_mm_set_pd(fX,fY), _mm_set1_pd(1.0 / 16.0)); CUtils::CallFunction(_mm_cvtsd_f64(tmp2), _mm_cvtsd_f64(_mm_unpackhi_pd(tmp2,tmp2)) ); >:-B , producing this assembly code: _Z1gv: movsd fY(%rip), %xmm0 movhpd fX(%rip), %xmm0 mulpd .LC0(%rip), %xmm0 movapd %xmm0, %xmm1 unpckhpd %xmm1, %xmm1 jmp CallFunction <...> .LC0: .long 0, 1068498944, 0, 1068498944
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
L-Spiro wrote:
#7: These are all not bad at improving speed, but is there something else you can do? Less duffy.
It's not the same as #3 and #4? Eh. I'll pass if that's the case. #8: struct SOMEstruct { int_least64_t i64Member2; void* pvMember1; long lMember0; char padding[ (sizeof(void*)*4) - sizeof(int_least64_t) - sizeof(void*) - sizeof(long) ]; }; I wouldn't use something such unportable as __int64. Rather, int_least64_t which can be found in stdint.h. The padding is here to make it properly aligned when stored in an array. On 32-bit, this pads to 16 bytes (otherwise 8+4+4 = 16 bytes) if the compiler does not choke on the zero-length array. On 64-bit, this pads to 32 bytes (otherwise 8+8+8 = 24 bytes). I was also thinking of possible limitations on various addressing modes and whether it makes sense to place some particular element at zero offset in order to make the access opcode shorter, but I cannot think f any reason why one of those elements should be prioritized over another.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
L-Spiro wrote:
#2: In this quiz, all of the code produces the desired output.
Maybe then you want to do vVec.z = ::sin(fA); vVec.y = -vVec.z; which is something the compiler should be able to do anyway; CSE is not exactly rocket science. Or maybe you want sincos(fA, &vVec.z, &vVec.x); vVec.y = -vVec.z;, which incidentally is more or less exactly what GCC 4.3.4 produces of the original code (ICC 11.1, too), sans redundant memory reads.
L-Spiro wrote:
#5: That being said, your code IS the best strict replacement for the example code; if we can not assume that the value will always be either 0 or 1, then your code is the best answer. And you are also the only person so far to give that answer.
Not exactly, ulSwitch = (~ulSwitch) & 1 may be even better. It was nowhere indicated that it should be assumed that the values of ulSwitch are 0 or 1 beforehand. If they are, one should use bool and the ! operator instead (since you are already going with C++). :) At least on GCC, ! for bool value becomes a xor by 1 on some platforms. If you insist, I can spell it here: ulSwitch ^= 1; #7: Oh you've got to be kidding me. If iTotal is never negative (apologies for missing indents, code and spoiler doesn't work together): do { unsigned n = iTotal >> 3; switch( iTotal & 7 ) { case 0: while(n-- > 0) { /* do something */; case 7: /* do something */; case 6: /* do something */; case 5: /* do something */; case 4: /* do something */; case 3: /* do something */; case 2: /* do something */; case 1: /* do something */; } } } while(0); If iTotal may be negative: #ifdef __GNUC__ # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) #else # define likely(x) (x) # define unlikely(x) (x) #endif do { int i = 0; if(likely((i < iTotal))) { unsigned n = (iTotal+7) >> 3; switch( (iTotal) & 7 ) { case 0: do { /* do something */; case 7: /* do something */; case 6: /* do something */; case 5: /* do something */; case 4: /* do something */; case 3: /* do something */; case 2: /* do something */; case 1: /* do something */;} while(--n > 0)); } } } while(0); You may also be looking for a less duffy solution: { int i=0; for(; i+4 <= iTotal; i += 4) { /* code, code, code, code */ } switch(iTotal-i) { case 3: /* code */ case 2: /* code */ case 1: /* code */ default:break; } } But beware that manual loop unrolling, which the compilers are often capable of doing themselves, robs the compiler of its oversight on opportunities for loop vectorization.
Post subject: Re: Fun Quiz
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
#1: Hard to guess what you are going for here. Maybe it's related to the fact that the variables are still going to be passed as doubles, and you think double division would be more efficient than float division? I shrug. #2. My guess is that this is not the proper formula for whatever vector calculation you are going for in here. Maybe you want a sin(fA)-cos(fA) somewhere. #3: Casting after subtracting 1UL? Well that's weird. I'd do -1 after the cast. That is highly suspect. In fact, if I want to loop backwards, I prefer this: for(size_t s = vvector.size(); s-- > 0; ) #4: Initializing I to 0UL probably is not a problem, but it's weird. Is vVector a vector of unsigned longs? Also, you haven't considered the case of the vector being empty -- in that case you see, 0 is not the maximum; NaN is. :) #5: "wrong"? eh. Well, if this is what you want... ulSwitch = (ulSwitch & 1)^1; #6: "wrong"? eh. Do you want anding and shifting? I'll pass. The compiler can do that. If you want to imply that you wanted :16 bit fixed-point math, just replace 16 with 65536. #7: I'd use lowercase for i. #8: I wouldn't use hungarian notation. Oh, and you may want to rearrange the elements so that int64 comes first and the others come last; this saves some space on 32-bit platforms, but not on 64-bit ones.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Warp wrote:
Fun with templates. (Not for the faint of heart.)
Primordially, one is inclined to ask… is that C++? Then again, I've got very similar blank stares regarding this PHP code:
    $keys = array_filter(someParser::GetAllSomeKeys(),
                create_function('$key', "return \$key['type'] == 'some_info';"));
Even though that is fundamentally much more basic. For the record, this code is functionally equivalent to this:
    $keys = Array();
    foreach(someParser::GetAllSomeKeys() as $index => $value)
        if($value['type'] == 'some_info')
            $keys[$index] = $value;
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Derakon wrote:
One question: how is subtracting '0' equivalent to bitwise-anding 7? '0' is 48, or 110000 in binary; 7 is 111 in binary. Let's try 57, or 111001. Subtracting off '0' gives 1001 (9); bitwise-anding 7 gives 001 (1).
Characters 0123456789 are in the ASCII range 0x30 .. 0x39. In this program, only characters 01234 (0x30..0x34) were used. '4' - '0' gives the value 4. 0x34 & 0x07 gives the value 4. '0' - '0' gives the value 0. 0x30 & 0x07 gives the value 0. 0x39 (57, '9') is outside the set of '0', '1', '2', '3' and '4' for which the expression was written to work and give proper values. It would also work for '5', '6' and '7', but not for '8' or '9'.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
As I wrote, you don't need to set any path variables (unless your svn executable is not in any of the directories indicated by your PATH variable, and even then, you can refer to the svn binary by its full/relative pathname). Also, you're now consistently mixing up repository paths with executable paths. If your svn executable is found without problem without any path setting (i.e. svn help shows a message from svn), you do not need to touch your PATH setting. What it is that you want to checkout? Just put that repository address on the svn commandline, after the word "co", and you're accomplishing the checkout.
Post subject: Re: Question about path variables in Linux
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
PATH is meant for listing those paths from which executables (i.e. programs) are to be looked for when you type a program's name without its pathname. However, your use of %SVN% suggests that what you want to do is to add repository paths to some common variable. Please explain carefully what it is you actually want to accomplish. In general, if you want to checkout some remote repository, you don't need to set up any variables. Just do this:
svn co <repository address here> <object name here>
For example:
svn checkout svn://svn.videolan.org/libdvbpsi/trunk libdvbpsi-trunk
(co is short for checkout, either word will work. I copypasted from [1].)
Post subject: How does one write obfuscated C code?
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Bisqwit wrote:
I first wrote the program in a clean manner, then compressed it by reducing all variable names and using the operators in a funny way
Let me post an example of such an iterative process. Here's a C program which produces season's greetings ― a different greeting depending on time of day.
#include <sys/time.h>
#include <stdio.h>
int main(void)
{
    time_t t;
    struct tm* tm;
    
    t = time(NULL); /* Get current time in seconds */
    tm = localtime(&t); /* Transform a timestamp to broken-down time, relative to user's timezone */
    
    switch(tm->tm_hour) /* Choose action from the hour value */
    {
        case 4:case 5:case 6:case 7:
        case 8:case 9:case 10:case 11:
            printf("Good morning!\n");
            break;
        case 12:case 13:case 14:
            printf("Good day!\n");
            break;
        case 15:case 16:case 17:
            printf("Good afternoon!\n");
            break;
        case 18:case 19:case 20:case 21:
            printf("Good evening!\n");
            break;
        default:
            printf("Good night!\n");
            break;
    }
    return 0;
}
This is revision 1. Anyone who knows the basic syntax of C can read exactly what happens here without strain. Now, to make it shorter by using data as a substitute for working logic:
#include <sys/time.h>
#include <stdio.h>
int main(void) /* revision 2 */
{
    static const char* const words[] = {"morning","day","afternoon","evening","night"};
    static const int per_hour[24] = {4,4,4,4, 0,0,0,0,0,0,0,0, 1,1,1, 2,2,2, 3,3,3,3, 4,4};

    time_t t;
    struct tm* tm;
    int greeting_index;
    
    t = time(NULL);
    tm = localtime(&t);
    
    greeting_index = per_hour[ tm->tm_hour ];
    printf("Good %s!\n", words[ greeting_index ] );
    return 0;
}
Furthermore, reduce the syntax:
#include <sys/time.h>
#include <stdio.h>
int main(void) /* revision 3 */
{
    static const char* const words[] = {"morning","day","afternoon","evening","night"};
    static const int per_hour[24] = {4,4,4,4, 0,0,0,0,0,0,0,0, 1,1,1, 2,2,2, 3,3,3,3, 4,4};

    time_t t = time(NULL);
    struct tm* tm = localtime(&t);
    
    return printf("Good %s!\n", words[ per_hour[ tm->tm_hour ] ] );
}
Express the data in a manner that reduces less source code space:
#include <sys/time.h>
#include <stdio.h>
int main(void) /* revision 4 */
{
    static const char* const words[] = {"morning","day","afternoon","evening","night"};
    static const char per_hour[24+1] = "444400000000111222333344";
    time_t t = time(NULL);
    struct tm* tm = localtime(&t);
    return printf("Good %s!\n", words[ per_hour[ tm->tm_hour ] - '0' ] );
}
Reduce number of redundant variables, simplify expressions, and shorten the variable names:
#include <sys/time.h>
/* #include <stdio.h> - not needed, guessed prototype for printf() is good enough */
int main(void) /* revision 5 */
{
    static const char* const w[] = {"morning","day","afternoon","evening","night"};
    time_t t = time(0);
    return printf("Good %s!\n", w[ "444400000000111222333344"[ localtime(&t)->tm_hour ] & 7 ] );
}
Finally, remove redundant white-space:
#include <sys/time.h>
int main(void)/* revision 6 */{time_t t=time(0);
static const char*const w[]={"morning","day","afternoon","evening","night"};
return printf("Good %s!\n",w["444400000001112223333444"[(localtime(&t))->tm_hour]&7]);}
In hindsight, yet one more data reduction:
#include <sys/time.h>
int main()/* revision 7*/{time_t t=time(0);return printf("Good %s!\n",
"morning\0day\0afternoon\0evening\0night"-194+2*"ppppaaaaaaaaeeegggllllppp"[localtime(&t)->tm_hour]);}/* 194 comes from 'a'*2 */
Or:
#include <sys/time.h>
int main()/* revision 7b*/{time_t t=time(0);return printf("Good %s!\n",
"day\0night\0morning\0evening\0afternoon"-64+"DDDDJJJJJJJJ@@@ZZZRRRRDD"[localtime(&t)->tm_hour]);}
Or:
#include <sys/time.h>
char*d="''''--------###===5555'' Good %s!\n\0day\0night\0morning\0evening\0afternoon";
int main()/* revision 8*/{time_t t=time(0);return printf(d+25,d+d[localtime(&t)->tm_hour]);}
If you rely on the fact that time() returns an int (or a long), and that the value measures seconds since 1970-01-01 00:00 GMT, and you know your timezone, you can discard localtime() and simply calculate the hour from the time() return value by modulo mathematics, and you could discard the one #include. For the sake of portability, we'll skip that. Anyway, this is how such messy source code is produced. It has its uses in IOCCC, novelty and code generation, but not when it is meant to be maintained by humans.
Editor, Experienced Forum User, Published Author, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
nfq wrote:
I watched your youtube video too, and you write really fast. Do you use a normal "qwerty" keyboard layout?
Thanks for watching. I do type fast, but the recording process was lagged somewhat, which artificially increased my apparent typing speed by a noticeable percentage. Which is good, because just like with TASes, it improved the entertainment (quality/quantity ratio). I use qwerty. Dromiceius> The article you linked to does not talk about QBasic's tokenization, though. That is closer to what C64 did. QBasic does not allow the meaning of program to change by tokenization/whitespace removal. (ANDY is a legal variable name in QB.) Arflech> That code was not really meant to be human-read, either. It is autogenerated by a program I wrote. (I.e. I first wrote the program in a clean manner, then compressed it by reducing all variable names and using the operators in a funny way, and then I fit it into C strings to be outputted by this intgen program, whose output you see here.) I posted it to provide contrast to the other post.