Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : General : DRODscript code golf (Another dumb sort of idea.)
New Topic New Poll Post Reply
Poster Message
Xindaris
Level: Smitemaster
Avatar
Rank Points: 887
Registered: 06-13-2015
IP: Logged
icon DRODscript code golf (+2)  
I recently perused some samples of code golfing over on stackexchange. It seems like there are all kinds of insane, obtuse coding languages, including things only using limited character sets (or just the word "chicken") and crazy geometrically based or nuclear-reactor inspired "languages".

It got me thinking: DROD's language is a little obtuse, but it's not Hexagony obtuse. Still, it could be interesting to create some basic programming challenges that take advantage of drodscript's unique property of existing inside of a video game with a player and a set of other objects in the room with their on fixed, predefined behaviors. In theory, any task you want to be script could be supplemented by things like roaches and doors and pressure plates. There even exists a hold (I forget which) in the Holds board which predates scripting, using the player's path through the level as the only method of computation.

So, here's the sort of rules I might propose for a DRODscript-based code golf:
-You must build a single room to accomplish the task. Give the player an "input method" which allows them to enter an integer one digit at a time by moving in a clearly-defined manner (or whatever the task should take as input).
-Your score is based entirely on how many lines of DRODscript you use. You can choose to split this across multiple characters, and lines of script used in a defined character type with multiple instances only count one time, no matter how many instances there are. Using DROD elements in the room is allowed and highly encouraged, since this could save you lines of code if used cleverly.
-The player should be expected to "type" their input, then do something to indicate the computation should start. After this the player will wait as long (by which I mean as many turns) as necessary for the "output" to appear, which can be speech text, images, or whatever, as long as it's clear what the output is to the player.

An example task might be to give the nth fibonacci number, where n is the integer the player enters--with the understanding that DROD's capacity for big numbers is limited, so even the best code will only be able to cope for n's so large. I'm not totally sure how a quine task would work in this environment, but it would at least be interesting to explore, I suppose.

I don't expect a whole lot of interest in this. I feel like amid the people who do DROD architecture, the number interested in DROD scripting is even smaller. But hey, if there were a lot of interest it would be prime material for a contest, right? Voting could be based on how "cool" the implementation is, with bonus points for the winners in "least lines of code".

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 06-09-2020 02:43 AM]
06-09-2020 at 02:33 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
averagemoe
Level: Master Delver
Avatar
Rank Points: 274
Registered: 03-22-2012
IP: Logged
icon Re: DRODscript code golf (-1)  
Since this isn't in the contests thread, I choose to talk about other things involving DRODScript code golf.

It's actually only tangentially related, but I've been writing a couple of scripts that need to scan a large portion of the room tile by tile. The simplest form of my algorithm for moving on to the next tile looks something like this.

  If ... 
        Wait until var "_MyScriptX" < 37
     Set var "_MyScriptX" + 1
  Else If 
        Wait until var "_MyScriptY" = 31
     Set var "_MyScriptX" = -9999
     Set var "_MyScriptY" = -9999
     Go to (whatever label)
  Else 
     Set var "_MyScriptX" = 0
     Set var "_MyScriptY" + 1
  If End

That'll make it look at every tile in the room if both _Myscript variables start at zero.

But, if it's for a specific room where, say, the top 5 rows are completely taken up by walls, or for whatever reason don't need to be scanned, then you can just set __MyScriptY to 5 right from the primer, and have it start on that row. Don't need the 2 columns on the far right? Set the command that checks the _MyScriptX value to wait until it's 35. Reduce the number of times it has to go through the loop.

In fact, it doesn't have to scan from left to right and top to bottom. If it counts something until it reaches a threshold that's more likely to be reached towards the southeast corner, set the variables to the max values at the start, subtract 1 instead of adding, and wait until they get to the numbers in the coordinates of the northwest corner. Or have it add to one value, and subtract from the other. You can even get it to scan vertically first by swapping the checks for X and Y.

Even better, if there's rows or columns near one of the edges that will only ever have any of what you're looking for towards one of the ends, you don't need to set the starter value to the same number that it resets to when it finishes with a row/column. Make the scanner start on the first tile that could possibly return a positive result.

____________________________
Black Lives Matter. And I don't mean that exclusively. Lives of all colors matter.

[Last edited by averagemoe at 06-09-2020 03:46 PM]
06-09-2020 at 05:51 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Someone Else
Level: Smitemaster
Avatar
Rank Points: 1184
Registered: 06-14-2005
IP: Logged
icon Re: DRODscript code golf (0)  
I'd be up for some golf! It'd have to be a little more complex than the fibbonacci numbers, though - odds are you could get pretty high without any scripting at all.
06-10-2020 at 02:31 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 887
Registered: 06-13-2015
IP: Logged
icon Re: DRODscript code golf (0)  
Yeah, fibonacci was just an example task. I was under the impression (for some reason) that DROD could only handle integers, but a quick test has proven me wrong. In addition to numerical stuff, it could be interesting to specify a nxn part of the room as a "display" and have a task of making it look a certain way based on input. Like, make a triangle, square, or "circle" of wall depending on whether the first digit of the input is 1, 2, or 3.

I'm pretty sure the last time I did a "scan the room for this object" task, I chose to split scanning vertically and scanning horizontally into two separate routines, one of them (the vertical one I think?) looping while calling the other with gosub, and then the other one would loop until it was done, then return. This was for something that happened one time to check for challenge completion, so it didn't need to be particularly memory-efficient.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 06-10-2020 04:26 AM]
06-10-2020 at 04:24 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Dischorran
Level: Smitemaster
Avatar
Rank Points: 2067
Registered: 09-10-2005
IP: Logged
icon Re: DRODscript code golf (+3)  
Don't forget that a given script has a command limit per turn before it gives up and declares the script infinite.

I got around it with Conway's Game of Life by spawning subcharacters and blowing up people's computers in the process. Be better than me.

____________________________
Click here to view the secret text

06-10-2020 at 09:07 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Rabscuttle
Level: Smitemaster
Avatar
Rank Points: 2175
Registered: 09-10-2004
IP: Logged

File: Fibonacci.hold (1.5 KB)
Downloaded 2 times.
License: Public Domain
icon Re: DRODscript code golf (+3)  
Scriptless Fibonacci numbers in binary.

Hit the orb to go to the next value.
(um, don't continuously hit it or the stalwart will break.)

Overflows after 987

[Last edited by Rabscuttle at 06-11-2020 01:28 PM]
06-11-2020 at 01:22 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 887
Registered: 06-13-2015
IP: Logged
icon Re: DRODscript code golf (+1)  
Nonetheless, accomplishing a heavy-computation task in a single turn via spawning subcharacters would be kind of hilarious. It makes me imagine an alternative programming challenge where the goal is to do something in as few turns as possible.

That's a neat counter, Rabscuttle, although the "display" isn't quite as clear as a character directly speaking the result number would be. This sort of thing is why a real golf challenge would need some clear rules on what kind of display is required, I guess; the script to take the "output" from this and turn it into a number variable to be spoken would probably be bigger than scripts that just compute the number directly.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 06-11-2020 06:34 PM]
06-11-2020 at 06:32 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Rabscuttle
Level: Smitemaster
Avatar
Rank Points: 2175
Registered: 09-10-2004
IP: Logged

File: Fibonacci.hold (3 KB)
Downloaded 2 times.
License: Public Domain
icon Re: DRODscript code golf (+3)  
Scriptless Fibonacci numbers in decimal with 7 segment display :P

Control-Wait twice to advance to the next value.

[Last edited by Rabscuttle at 06-12-2020 01:10 PM]
06-12-2020 at 01:09 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : General : DRODscript code golf (Another dumb sort of idea.)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.