[Project Gamma] Math: Silo Launching
Moderator: Defcon moderators
Ahahah, just a joke. The best way to kill the opponents is to stop the api page. No opponents for midnight!!
I hope to see him/it soon..
edit: Thank you Montyphy
I hope to see him/it soon..
edit: Thank you Montyphy
Last edited by Zorotama on Tue Feb 23, 2010 5:21 am, edited 1 time in total.
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
Thanks again Montyphy!
Zoro, look above you.
Thank you Montyphy and Zoro! I was able to 'fix' my hanging/crashing Defcon issue. Can even take screenshots too! Project Gamma is back on track! Also, didn't have to redo my code for something slower, like I thought I would *jabatrolfbot*.
Zoro, look above you.
Thank you Montyphy and Zoro! I was able to 'fix' my hanging/crashing Defcon issue. Can even take screenshots too! Project Gamma is back on track! Also, didn't have to redo my code for something slower, like I thought I would *jabatrolfbot*.
Smoke me a kipper, I'll be back for breakfast...
- roflamingo
- level3
- Posts: 404
- Joined: Fri Jan 19, 2007 10:25 am
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
I'm actually not 100% sure.
Here is what I do know:
A. You can have loads of blocks between 'StartLongTask()' and 'end)', so long as the YieldLongTask() for each block is located in the correct spot. I am pretty certain you only need one per block. As for the correct spot, well the best I can guess is: repeat loops: just before 'until'. for loops: either just before 'end', or perhaps after the 'end', didn't have time to test that. Currently, they're just before 'end', (for .. do stuff .. YLT .. end). Apparently, you can also have more than one StartLongTask()/end) in a function, but I am not sure how to make that work properly or what the drawbacks are. I cleaned up my YieldLongTask()s.
B. I don't know if this really did anything, but I changed 'repeat, for, until' table.insert blocks to just for loops. Not sure why I had a for loop in a repeat loop for that bit.
C. I removed all commands after 'end)'
D. I use a number of
functions to make sure a given object is only entered into a given table once (avoid duplicates). I had specific Set(), SetS(), Setb(), etc set up, but was using the generic Set() a bunch of times within the same function. Corrected that to give each unit table it's own 'Set()'.
Here is what I do know:
A. You can have loads of blocks between 'StartLongTask()' and 'end)', so long as the YieldLongTask() for each block is located in the correct spot. I am pretty certain you only need one per block. As for the correct spot, well the best I can guess is: repeat loops: just before 'until'. for loops: either just before 'end', or perhaps after the 'end', didn't have time to test that. Currently, they're just before 'end', (for .. do stuff .. YLT .. end). Apparently, you can also have more than one StartLongTask()/end) in a function, but I am not sure how to make that work properly or what the drawbacks are. I cleaned up my YieldLongTask()s.
B. I don't know if this really did anything, but I changed 'repeat, for, until' table.insert blocks to just for loops. Not sure why I had a for loop in a repeat loop for that bit.
C. I removed all commands after 'end)'
D. I use a number of
Code: Select all
function Set (list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
functions to make sure a given object is only entered into a given table once (avoid duplicates). I had specific Set(), SetS(), Setb(), etc set up, but was using the generic Set() a bunch of times within the same function. Corrected that to give each unit table it's own 'Set()'.
- roflamingo
- level3
- Posts: 404
- Joined: Fri Jan 19, 2007 10:25 am
roflamingo wrote:That's great. Making the code more efficient will make it faster and easier to read later.
I had my forward radar loop almost all working, introducted something, and now it hangs, and I can't figure it out either It was all I needed before I started defensive radar and subs!
sounds like you just need to put in a yield.
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
I've had several bits of code cause hangs on me. In general, if you have any kind of loop, it must (I think) be wrapped in a StartLongTask() with an appropriate YieldLongTask(). Might only be for Repeat or While, but I'm fairly certain that For is included as well. Although, While loops always gave me problems, never could get a single one to work.
Smoke me a kipper, I'll be back for breakfast...
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
It looks like you need some explanation of how long tasks are handled, I'm no expert but it looks pretty simple, here's what I infer:
StartLongTask
This takes a function as an argument, and takes a constant (very small) amount of time to execute. It simply adds the task to a queue
YieldLongTask
A task will keep executing until it finishes, or YieldLongTask is called. Yield stops executing the task until it is resumed
WorkOnLongTasks
This will pick the task at the front of the queue, and start running it (either from the start, or from wherever YieldLongTask was last called). The task will not stop until it finishes or Yield is called.
So, basically, you should call work on long tasks just once every update step. You could call yield everywhere inside a loop (any loop, or possibly after calling a really long running method). You should start every large task with startLongTask.
Check out the stuff for Joshua, and you'll see what I mean
StartLongTask
This takes a function as an argument, and takes a constant (very small) amount of time to execute. It simply adds the task to a queue
YieldLongTask
A task will keep executing until it finishes, or YieldLongTask is called. Yield stops executing the task until it is resumed
WorkOnLongTasks
This will pick the task at the front of the queue, and start running it (either from the start, or from wherever YieldLongTask was last called). The task will not stop until it finishes or Yield is called.
So, basically, you should call work on long tasks just once every update step. You could call yield everywhere inside a loop (any loop, or possibly after calling a really long running method). You should start every large task with startLongTask.
Check out the stuff for Joshua, and you'll see what I mean
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
- roflamingo
- level3
- Posts: 404
- Joined: Fri Jan 19, 2007 10:25 am
Thanks M for clearing it up. Your description is kind of what I suspected. I guess I don't know how to tell if a task is 'long' or not.
Almost everything in the code is in some kind of loop. And I have only done placement of ground installations so far!
Side Note:
Did we ever clear up if bot vs. bot was possible?
Almost everything in the code is in some kind of loop. And I have only done placement of ground installations so far!
Side Note:
Did we ever clear up if bot vs. bot was possible?
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
- roflamingo
- level3
- Posts: 404
- Joined: Fri Jan 19, 2007 10:25 am
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
Who is online
Users browsing this forum: No registered users and 20 guests