[Project Gamma] Math: Silo Launching

General discussion about Defcon

Moderator: Defcon moderators

Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Tue Feb 23, 2010 5:19 am

Last edited by Montyphy on Tue Feb 23, 2010 5:21 am, edited 1 time in total.
Uplink help: Check out the Guide or FAQ.
Latest Uplink patch is v1.55.
User avatar
Zorotama
level5
level5
Posts: 1508
Joined: Thu Nov 13, 2008 4:03 am
Location: 64x80

Postby Zorotama » Tue Feb 23, 2010 5:20 am

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
Last edited by Zorotama on Tue Feb 23, 2010 5:21 am, edited 1 time in total.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Tue Feb 23, 2010 7:40 am

Thanks again Montyphy!

Zoro, look above you. :P

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*. :D

:P
Smoke me a kipper, I'll be back for breakfast...
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Tue Feb 23, 2010 7:51 am

What was the fix?
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Tue Feb 23, 2010 4:54 pm

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

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()'.
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Tue Feb 23, 2010 5:59 pm

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! :roll:
Montyphy
level5
level5
Posts: 6747
Joined: Tue Apr 19, 2005 2:28 pm
Location: Bristol, England

Postby Montyphy » Tue Feb 23, 2010 6:02 pm

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! :roll:


sounds like you just need to put in a yield.
Uplink help: Check out the Guide or FAQ.

Latest Uplink patch is v1.55.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Tue Feb 23, 2010 6:05 pm

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...
User avatar
DinoSteve
level3
level3
Posts: 251
Joined: Fri Aug 21, 2009 10:36 pm
Location: California, US

Postby DinoSteve » Tue Feb 23, 2010 6:58 pm

When and how to use yield depends on the size of the loop and how you've split your code up
The above post is not intended as an attack on you. It's not about making you look stupid for not searching. It merely states the facts. Please don't be offended.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Tue Feb 23, 2010 7:18 pm

Details? :P
Smoke me a kipper, I'll be back for breakfast...
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Tue Feb 23, 2010 8:36 pm

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 :)
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Tue Feb 23, 2010 10:01 pm

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?
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Tue Feb 23, 2010 10:02 pm

roflamingo wrote:Side Note:
Did we ever clear up if bot vs. bot was possible?

As far as I know, no. (both we didn't', and it's not possible) :P
Smoke me a kipper, I'll be back for breakfast...
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Tue Feb 23, 2010 10:18 pm

Ace Rimmer wrote:
roflamingo wrote:Side Note:
Did we ever clear up if bot vs. bot was possible?

As far as I know, no. (both we didn't', and it's not possible) :P


That's really too bad, because my bot would destroy your bot. Just as soon as I write some code to shoot and fire at stuff. :lol:
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Tue Feb 23, 2010 10:19 pm

I highly doubt it, as soon as my bot can use it's navy. :P
Smoke me a kipper, I'll be back for breakfast...

Return to “General”

Who is online

Users browsing this forum: No registered users and 20 guests