CRPL Ideas/Questions

Started by Tiuipuv, December 24, 2012, 04:44:06 PM

Previous topic - Next topic

Grauniad

Swap:

  4 5 swap

Stack notation:

4 5 -- 5 4
A goodnight to all and to all a good night - Goodnight Moon

florrat

Looks good, but rather limited. Are there ways to swap elements further down the stack?

Grauniad

A goodnight to all and to all a good night - Goodnight Moon

asmussen

Quote from: florrat on December 26, 2012, 08:03:02 PM
Looks good, but rather limited. Are there ways to swap elements further down the stack?

In any stack oriented language, by definition you are pretty much limited to only being able to manipulate the data at the top of the stack. It does take some getting used to when you first learn to think that way, but there are definite advantages to it when it comes to actually implementing the language.
Shawn Asmussen

ShadowDragon7015

is there a way to make the CRPL tower go back and forth along a line like it is patrolling and then have it fire spores a certain distance forward towards the command center? I mostly want to know about the firing the spores in one direction.
Hiding the golden creeper for years to come.

Grauniad

Quote from: ShadowDragon7015 on December 27, 2012, 11:54:43 AM
is there a way to make the CRPL tower go back and forth along a line like it is patrolling and then have it fire spores a certain distance forward towards the command center? I mostly want to know about the firing the spores in one direction.
That all seems possible.  Movement commands and firing spores at specific targets are included. So is the ability to obtain the location of a CN (I think).
A goodnight to all and to all a good night - Goodnight Moon

asmussen

Is the CRPL tower an enemy unit that must be destroyed for map victory (On maps where destroying the enemy is the objective)? Is it possible to somehow setup a CRPL tower with a script that will run for the entire time the map is being played, without being subject to being destroyed by player activity?
Shawn Asmussen

lurkily

Virgil in his demo queued random coordinated for his movements - if you simply queued movements between two mapper-entered coords instead, you should get the behavior you describe.

As to whether it must be destroyed, there's no word on that yet, but I am hoping, personally, that this decision will rest in the mapper's hands.

hoodwink

Quote from: asmussen on December 27, 2012, 12:57:35 PM
Is the CRPL tower an enemy unit that must be destroyed for map victory (On maps where destroying the enemy is the objective)? Is it possible to somehow setup a CRPL tower with a script that will run for the entire time the map is being played, without being subject to being destroyed by player activity?
I remember somebody mentioning somewhere that it will be possible to set up a 'ghost' tower that doesn't have a physical presence on the map (or similar), but still runs a script. That way, a script will not be subject to being nullified, since it's tower is not on the list of things to be obliterated.
Stare not into the abyss, or it has hasten in its approach.
~ Hoodwink (thesmish, smish777 or sigil)

lurkily

If a tower can change its image (in particular, change it to 'none') and remove itself from targeting by player units such as nullifiers, that will be true.

All of these things are things that I think of as necessary to get the best bang for the buck with this tower, but so far V has said nothing definitive on the subject.

Tiuipuv

I didn't want to leave something in my code that didn't mean anything. So, I have created code to define GetDeepestCreeperCoords. Here it is, without any notations:

1 1 1 1 GetCreeper SetVar0 GetVar0

600 1 do
400 1 do
I J GetCreeper GetVar0 gt if
drop drop I J I J GetCreeper SetVar0
endif
loop
loop


And, as usual, it brought my attention to lots of little points.

#1
The stack is not cleared after every line, right? As long as it isn't cleared, then it shouldn't matter if things get put in the same line or not. For instance, creating creeper at current coords looks like this:

CurrentCoords SetCreeper

But it could also look like this:

CurrentCoords
SetCreeper


So in theory, all of my code could go on one line, or only one word per line if I wished. Is that correct?

#2
There also must be some command for removing an item from the stack (I think), and I found one listed as "drop" from Grauniad's link http://astro.pas.rochester.edu/legacy/Forth/stack.html. Where I have drop it would remove the top item from the stack.

#3
In the video I saw an "lt", and it seemed to have the same function as less than. So, in my code, I use a "gt" for greater than.

#4
Also in my code, I use a variable. I set it up like Virgil's GetTimer0 and SetTimer0 in the video, but I'm not certain that's how it would be written.

#5
I think that what my code does requires either

1. a variable
or
2. a way to interchange items on the stack

Which would be more cpu intensive?

#6
The loops I use are large, would it perhaps go over a limit on loop size? If so, how could that be avoided?

#7
In what order does the loop execute? Does it start at 600 then go to 1, or the other way around? Does the larger number have to be first?


In case I did something wrong, I want you to be able to correct me exactly. So, here is how I foresee the stack history as it executes this code:

1 1 1 1 GetCreeper SetVar0 GetVar0

#1
#1 1
#1 1 1
#1 1 1 1
#1 1 (1 1 Creeper Amount)
#1 1
#1 1 (1 1 Creeper Amount)

I J GetCreeper GetVar0 gt if

#1 1 X
#1 1 X Y
#1 1 (X Y Creeper Amount)
#1 1 (X Y Creeper Amount) (1 1 Creeper Amount)
#1 1 (True/False)
#1 1

#if (X Y Creeper Amount) > (1 1 Creeper Amount)

drop drop I J I J GetCreeper SetVar0

#1
#Empty
#X
#X Y
#X Y X
#X Y X Y
#X Y (X Y Creeper Amount)
#X Y

#1

I J GetCreeper GetVar0 gt if

#X Y A
#X Y A B
#X Y (A B Creeper Amount)
#X Y (A B Creeper Amount) (X Y Creeper Amount)
#X Y (True/False)
#X Y

#if (A B Creeper Amount) > (X Y Creeper Amount)

drop drop I J I J GetCreeper SetVar0

#X
#Empty
#A
#A B
#A B A
#A B A B
#A B (A B Creeper Amount)
#A B

#Goto #1. Repeat until finished.


This should finish with a single X and Y coordinate pair where the creeper is deepest (or tied for deepest). This code would go where I previously put GetDeepestCreeperCoords.
What?! Why? How? Just work, you field!

Michionlion

variables are already implemented, use <-varName to push a var onto the stack, ->varName to pop an item from the stack and put it in a variable.  also, 'drop' is 'pop'.  And from my experience, yes, the stack is not cleared after every line.
"Remember kids, the only difference between science and messing around is writing it down."
                                                                                                                         - Adam Savage

My website
My CW1, and CW2 maps!

tornado

wait in the video Virgil entered current cords to emit creeper from the crpl tower
but what if you enter a random location on the map
Now CEO of Particular Endeavors. http://knucklecracker.com/forums/index.php?topic=23752.new#new
We apologize for all inconveniences that we caused.
Quotefirst, you have to imagine a very big box, fitting inside a very samll box.
then, you have to build one

Michionlion

Quote from: tornado on January 06, 2013, 04:11:17 AM
wait in the video Virgil entered current cords to emit creeper from the crpl tower
but what if you enter a random location on the map

CurrentCoords just pushes two values onto the stack - your current x coord, and your current y coord.  If you put random numbers there, then the tower would create creeper at those coords.
"Remember kids, the only difference between science and messing around is writing it down."
                                                                                                                         - Adam Savage

My website
My CW1, and CW2 maps!

Grauniad

Quote from: tornado on January 06, 2013, 04:11:17 AM
wait in the video Virgil entered current cords to emit creeper from the crpl tower
but what if you enter a random location on the map
Hello Tornado.

That was a good catch. Conceptually there is a disconnection between a tower's physical location and the actions it can take. Which is why Virgil will be introducing a "hidden" tower type. (More about this in a second - it gets very complicated.)  You should really think of a tower as merely a vehicle to introduce programming capability to a map.  The tower can affect terrain; launch spores; create Digitalis or runners; create or alter creeper and anti-creeper at any location on a map.

Destroying the tower might not even be a game completion option (or it may - there are special actions the tower con perform once, when it gets destroyed),

To avoid the visual confusion that may arise when a tower performs remote actions, and when destruction of the tower is not a game objective, the map maker can designate the tower as hidden - it won't appear on the map, yet it will still perform actions on that map.

HTH.
A goodnight to all and to all a good night - Goodnight Moon