TradeWars Proxy Notes.md 6.1 KB

TradeWars Proxy ++

TODO

  • I have the ANSI music from Yankee Trader. Sound "works" sort-of using padsp syncterm202109 but crackles randomly. (If I remember correctly, the static is more frequent on slower cpus/David's system.) :cry:
  • VoyagerScript: BUG: Handle sectors to avoid. (Query the list, allow sectors to be handled that we should avoid)
  • Sectors of concern: Store sectors that show in density that are > 1000.
  • Move Failed: Show Why and Where. (Which sector, what's the density?)
  • Static linking the proxy to stuff into docker container. We dynamic link boost_threads, filesystem and log right now.
  • TradeDispatch -- return some value that says we've Traded/or there's nothing here to trade with. (Keep calling TradeDispatch until nothing -- then move on!)
  • MoveDispatch -- return success that we moved to a sector. (Should we give it two sectors that we want to trade with -- and have it move to the nearest/closest one?) That way we don't waste a move (going to the furthest one, only to move back to the nearer)?
  • make a program that reads the logs and feeds it into the director.
  • any problems -- exit and save your logs! we can simulate/reproduce the problem. :D
  • This can be the beginnings of tests. Navigate 4-5 sectors, test that the galaxy is set correct. Are the warps right, are the ports right.
  • If I go into a sector with a port, can I do computer/ask about that port? That might be a nicer way of exploring the galaxy -- no need to update ports, we'd already have the port's information! Yes, this works. We also get what we have in our holds. This is great for trading!
  • I'm able to tell which port I can start trading with, should I check that before moving? Or is it not worth it to waste X turns?
  • FAILED: I have fuel in my holds, ports are only selling fuel. 2021-11-03 00:26:03.586801 fatal ( director.cpp:252 ) Sector: 9994 2021-11-03 00:26:03.586900 fatal ( scripts.cpp:180 ) trades: falsetruefalse 2021-11-03 00:26:03.586945 fatal ( scripts.cpp:181 ) port0:"SSB" 2021-11-03 00:26:03.586985 fatal ( scripts.cpp:182 ) port1:"SBB" 2021-11-03 00:26:03.587059 fatal ( scripts.cpp:222 ) !have_buy: port 0 2021-11-03 00:26:03.401724 trace ( galaxy.cpp:478 ) find_trades: Port 9994,4 9873 2021-11-03 00:26:03.401771 trace ( galaxy.cpp:496 ) sector: 9994 and 987 tt:3 2021-11-03 00:26:03.401820 fatal ( director.cpp:487 ) Found 1 possible trade(s). 2021-11-03 00:26:03.401860 fatal ( director.cpp:488 ) 9994,987 : 3 2021-11-03 00:26:03.401899 fatal ( scripts.cpp:14 ) ScriptTrader::activate 9994 & 987 2021-11-03 00:26:03.401939 fatal ( scripts.cpp:21 ) 4 and 3
  • was able to trade ok with 987 & 15611....
  • I think there's a bug in the detect "burnt" ports. I don't think it takes into consideration ports that I've seen but not docked with (all percents 0). Whoops!
  • If there's a port that's BBB, and there's a SBS or BSS, it should use E.
  • We're not interested. If we're doing single trade (not trade pairs), I probably need to redock with the port.

BUG

  • terror: The trade empty flag wasn't set. Cargo in holds couldn't be sold, endless loop.

Things to Improve / Fix

  • Moving anywhere should be done in a safe manner. (Single step and density scan -- unless we just don't have any scanner!)
  • Trading -- know what we have as cargo and know what the ports are buying/selling. [AVOID: They don't want what we have -- going to the other port.] Possibly have an option to automatically jettison the cargo! (Or sell it off at nearby port?)
  • Any sectors with a high > 500 > 1000 density should be stored somewhere as "dangerous/of interest". [How will we handle sectors that have our own fighters/planets in them then?] Possibly do density scanner, and save those results as well...

  • Performance issues saving YAML. Loading is 1.5 secs. I think creating the YAML::Node tree is what is killing me. Maybe write the yaml manually?

  • When upgrading the planet, cargo is bought at full price. (Haggle there as well.)

  • When trading, we sometimes get "We're not interested". Figure out what we can adjust to get that to not happen.

Done ! yeah!

  • Stale port data: Warn about it. (If > 1 hour ago) (This revealed a meta data loading issue.)
  • Setup the prompt timeout. Display prompt + prompt_raw (to verify that this is working)
  • On the prompt, if there's a \r throw it away and everything left of it.
  • work on find trade pairs/find best/find ok trades. We have data to work with now.
  • define the functions (server_line, server_prompt [default to null/not set], client_input). And defaults "to_client, to_server" -- but those won't ever change.
  • * factory of shared_ptr of "director" ? (from dispatcher) so it gets parent / auto saves on ctor. Sounds like a complete mess. :(
    • Dispatcher
    • will have "echo" value -- so we can hide things (if we want) from the client. [Like loading ports and warps!]
    • Will have line (to process the most recent received line), and prompt (the most recent / current complete prompt from the server).
    • There will be obvious clear ways to send to client and server.
  • Storage. (We store a lot of data.) In python, we used JSON. I'm thinking right now that we should use sqlite. It's lightweight and mostly quick. (Maybe have dirty bit option so we can save only things that have changed?) This is OK up to the point where we have multiple users running through the proxy. Then what happens?

  • Adjust our trading -- I'd like to see us earning 5 XP (or better) for excellent trading. We're consistently earning 2 XP. 5 XP = 100% perfect trades. (I don't think that's going to happen.)

  • The dispatcher should use a stack (FILO). We should be able to create something (SafeMove) and give it a sector number. It will then be placed on the stack. Once it is done, it will be able to return "something" to signal success/failure. (Maybe have a selectable "callback" with the results?) "Something" being struct { int value, std::string text }. I have a callback, which works. I don't think I need a stack of chains.