Multithreading is complex,but would AT-LEAST this be possible (for each AI or MP opp)

Discussion in 'General Discussion' started by Spinelli, Feb 8, 2015.

Thread Status:
Not open for further replies.
  1. Spinelli

    Spinelli Banned

    Joined:
    Jan 28, 2012
    Messages:
    5,290
    Likes Received:
    32
    Idea
    I know multithreading is complex when it comes to the overall game engine, I always hear of all sorts of potential issues between timings, waiting for the other thread to complete, etc. etc. and that's why it can be extremely complex and much more difficult than it seems, however...

    Is there a way where ONLY the physics of the A.I. can "dynamically" be multithreaded? What I mean by "dynamically multithreaded", is, let's say you have a 12-thread CPU (Intel i7-5930K, 5820k, 4930k, and many others). Ok, so we have the "base game" which currently uses two threads (RF2 is currently a dual-threaded program). The game recognizes how many threads your CPU is capable of, so let's say RF2 knows you have 12-threads. Let's say it uses threads 1 and 2 (just an example, I believe the operating system's task scheduler decides which particular threads to use) for the base game, leaving threads 3-12 unused. Then, as soon as you add an A.I., the physics of that A.I. run in it's own thread, lets say thread #3. Then, you add another A.I., that A.I.'s physics are fully run under thread #4, and so on and so on. The 10th A.I. will be run on, in this example (12-thread CPU), thread #12. Then, the 11th A.I.s physics will be run on thread #3 (shared with the first A.I.s physics), the 12th A.I. will run under thread #4 along with the second A.I., and so on and so on.


    What Would This Achieve/Allow?

    Using the power of all our CPU's threads - of which most people have 4 or 8, and quite a few with 12 (and some even higher, but rarely) - would possibly allow the A.I. to use absolutely, 100% full, true, player physics. Exact same physics engine, exact tyre model, exact physics update rate, etc. Literally, the exact same physics engine in every way, shape and form to the absolute smallest detail that the player's car uses.

    Each car's physics will be on it's own thread, so I'm assuming (but I really don't know much about this stuff), that this would, for the most part, eliminate the complex and problematic timing issues of a particular workload being shared/divided between threads. Remember, the "base game" would still be running as it is now, just two threads, no changes there. It's just that each A.I. get's it's own specific thread.


    The Knock-On Effect

    Each A.I. getting it's own separate thread, and separate from the two threads the "base game" runs on, would be the freeing-up of the "base game's" threads those threads don't need to worry about A.I. physics calculations, leaving the "base game" with much more power available for it thereby increasing all sorts of potential of doing even more.


    The Battlefield Series: A Sort-of Example
    Battlefield is a great example - particularly BF3 and BF4. It's slightly different as it works for the online multiplayer opponents. When you play online, the more opponents there are, the more a higher threaded CPU will make a positive performance difference. With Battlefield, the game takes advantage of more threads for the online multiplayer data - slightly different than my rFactor 2 idea, but in Battlefied, it's still the same general idea being: The "base game" does not really take advantage of anymore threads than it was coded for; you can see this by playing offline single-player, there is hardly any difference between 4 threads, 8 threads, and 12 threads. Then - once you go online - the game knows how many threads your CPU has, and the more players online (I believe the max is currently 64) the more the game will take advantage of whatever amount of CPU-threads you happen to have.


    Doing It "The Battlefield" Way (MP opponents instead of AI)
    If the whole AI-with-full-physics-and-each-devoted-to-a-particular-thread thing I explained above cannot be done, then how about the Battlefield way where, single player doesn't take advantage, but online does (especially the more opponents there are)? Would that work? Remember, the "base game" doesn't have to change, it can still run as is in order to avoid all the complex timing issues associated with certain workloads across multiple threads.


    Final Thoughts
    The "AI way" would, I feel, would make a HUGE difference to the game. I believe there are a lot of people who play rFactor 2 offline and really, really value and cherish the whole offline experience. I can't believe how many threads I read about people still playing against AI, talking about AI driving styles, how to improve them, creating AIWs, videos of offline races, asking for championship/season creators, etc. In-fact, I was shocked the other day when I spoke to a forum "regular" who told me that he as almost NEVER been online with RF2. Well, imagine playing against A.I. with absolutely 100% player physics in every way, shape, and form. The "AI way" would also be much, much more demanding from a PC point of view and would really, really need to use the power of multiple threads. It isn't as vital to do the "Battlefield MP" way as, as it is, most people have no issues with large grids of cars online (or hardly), but then again, I've hardly raced in large grids - almost always under 10 - so I could be wrong.
     
    Last edited by a moderator: Feb 8, 2015
  2. Lgel

    Lgel Registered

    Joined:
    Jun 24, 2014
    Messages:
    1,267
    Likes Received:
    365
    I only play off line, and I must admit that I am quite satisfied of how it runs, as is, on good tracks.

    In some cases, I adjust in the AIW files of the track the values for worst, mid, and best values (best way to adjust AI, quite simple). In other extreme cases you can play with the tbc file to adjust the grip of opponents, you need to know how to repackage, but they are many videos explaining how on Youtube (and evidently this will cause mismatch on line).

    I don't say it can't be improved, I would be very satisfied if I could simply save the AI settings for a given track and series.

    I don't think that this aspect is what makes a potential customer try the demo and not buy the game afterwards, in my view it is one of the strong points of RF2.

    You have only to look at the posts of newcomers to know what is the problem more often raised.

    I can confirm you that a program with more than two threads is not efficient in many cases (independent threads should exchange constantly a lot of information about relative position of cars, resulting in a very high overhead).

    Cheers.
     
  3. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,345
    Likes Received:
    6,572
    Spinelli, the more complex the AI physics the more complex and difficult is the code to make them drive. This isn't just about CPU power - there seems little reason to spend increasing amounts of dev time working on AI that is already pretty good, and whose faults have basically nothing to do with the physics used for them.
     
  4. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,317
    Likes Received:
    2
    Agree with Lazza.

    The AI is a perfectly capable and mostly fair enemy, quite detailed possibilities to adjust their strenghts and weaknesses. To have such a great AI, first we'd need better setups for them, for each track. It doesn't make sense to run most high-detail physics on shaby default setups.
     
  5. stonec

    stonec Registered

    Joined:
    Jun 19, 2012
    Messages:
    3,399
    Likes Received:
    1,488
    Rewriting AI would like alter rF2 minimum recommendations. rF2 strength is that it has the best AI of any sim, which still runs even on a crap CPU, E6600 Core 2 from 2006 works fine. With more complex AI we have the situation as with Assetto Corsa, as soon as you add too many AI cars in AC you get the stupid "95% CPU occupancy" warning and physics fall out of real time. Wouldn't work very well with large grids.
     
  6. GCCRacer

    GCCRacer Banned

    Joined:
    Dec 12, 2012
    Messages:
    1,317
    Likes Received:
    2
    And besides... the player AI (especially Tire Model) is so demanding that merely multi-threading wouldn't offset it nearly enough.
     
  7. Spinelli

    Spinelli Banned

    Joined:
    Jan 28, 2012
    Messages:
    5,290
    Likes Received:
    32
    I personally don't believe this since currently only two threads are managing the player physics plus the rest of the entire game.

    Having this as an option, at least in the player.json file, would be sweet.
     
  8. Dalek

    Dalek Registered

    Joined:
    Apr 15, 2014
    Messages:
    39
    Likes Received:
    0
    1 - How do you syncronise the threads ? meaning stuttering, tearing disappearing and all the stuff you dont want in a sim. This is only the AI but will have an effect.

    2 - Do you really think that people who do this as their job havn't thought of it ? considering RF2 has the best netcode of the sims IMHO. Wouldnt the question be, why do they do it this way ?

    3 - there is millions of different PC setups out there, how do you make a system that runs ok on 1 thread but also on 12 ?


    And to finish on a humourous note, "imagine playing against A.I. with absolutely 100% player physics in every way, shape, and form", yeah, 20 AI race = 20pc's sitting in my house....
     
  9. Spinelli

    Spinelli Banned

    Joined:
    Jan 28, 2012
    Messages:
    5,290
    Likes Received:
    32
    You're so right; how can other games run on 4 threads? How can the Battlefield games run on more threads the more threads your CPU has and take advantage of them more when you're online in a big multiplayer map? How do some games take advantage of 6 core CPUs. 2 is the magic number, there is no way a game can run on more than 2 threads, after 2 threads, it's impossible, there will be "stuttering, tearing disappearing and all the stuff you dont want in a sim." Yes, you're so right, it's impossible. All those other games don't exist, it's just a figment of my imagination.

    One, it's the way it was designed years and years ago. And I never said that the "people who do this as their job" haven't thought about it.

    ?? No idea what this is even supposed to mean. Have you thought about actually trying to read and understand anything being said? Software can detect how many threads you have, the game wouldn't be designed to specifically have to use 12 threads. You're clearly not understanding anything I wrote in my original post and how some other games work.


    If the current game can support the player's physics, plus the rest of the game on just two threads, and I'm assuming the player physics on only 1 of those threads, then what's so hard to believe that another thread can do the work, and mostly just the work, of another 1-3 A.I.s?
     
  10. Dalek

    Dalek Registered

    Joined:
    Apr 15, 2014
    Messages:
    39
    Likes Received:
    0
    Soo, our point of reference is battlefield, with the most serious hitbox issues since 2005 ?

    I think the point that you are missing, and that Lgel pointed out to you, is that threads need to share information and be sychronised.
    Different types of games requires differenct compromises. RF2's netcode is fine, BF's net code, with all those threads is crappy, and thus since 2005.

    Multithreading is a PITA and research is still being done. http://cacm.acm.org/magazines/2014/...-reliable-with-stable-multithreading/abstract

    How many devs work on battlefield ? how many hours since 2005 ? ( BF2's netcode was bad, lagging hitboxes ) and they stil havn't fixed the issues? With the people, time, experience, knowledge ?
    Could this be partly beacause of multithreading ? I'm not a dev, so I cant answer that.

    The simple fact you try and tell people to do it the other way, when you do not know how to code (if i'm wrong, tell me and show me something ), and become condescending when someone tell's you otherwise means enough for me.


    Have a good day.

    Edit for spelling
     
  11. Lgel

    Lgel Registered

    Joined:
    Jun 24, 2014
    Messages:
    1,267
    Likes Received:
    365
    Please Spinelli, what would you think is someone wrote to you:

    "Have you thought about actually trying to read and understand anything being said"
    " You're clearly not understanding anything "?

    Try to accept the fact that other people not thinking like you are not your personal foes, and that they are welcome to say what they want in this forum as long as they stay polite.

    I fear this thread will end closed as many before for not following forum rules.

    Cheers.
     
  12. MarcG

    MarcG Registered

    Joined:
    Oct 4, 2010
    Messages:
    6,854
    Likes Received:
    2,234
    Spinellis getting a bad reputation for the above, see his locked thread for pure examples!
     
  13. gagipro

    gagipro Registered

    Joined:
    Feb 26, 2013
    Messages:
    473
    Likes Received:
    7
    Ai is very limited in rF2! They follow the AIW line.
    It's not like Arma or BF...
     
  14. Spinelli

    Spinelli Banned

    Joined:
    Jan 28, 2012
    Messages:
    5,290
    Likes Received:
    32
    Ok, take a breather, man. What is wrong with you? I had two ideas regarding reasons RF2 could use and benefit from multithreading. I'm not telling ISI to do it, what the...? I need to know how to code software just to bring-up and discuss some ideas for a game I'm like? Someone tells me otherwise? Excuse me, but you came on here defending the crap out of the game as if I tried to commit murder against it, and you also were talking as if you knew the answer (it can't be done, there's a reason why it's the way it is, you don't think ISI thought about this?, Etc. Etc.). as if you're the programmer from ISI, yet I'm the one who's being condescending? Geez.

    He was simply misunderstanding me. He said something along the lines of "how would other PCs be able to run the game if the game is meant to run on 12 threads?". That is not what I said, I said the game will just take advantage of as many threads as it can, wether it be 4.8,12, or 16. He was going-off as if he was the master programmer himself/herself at ISI, then he also makes a statement/question which implies something completely different to what I said.

    Way to contribute to the thread, very informative. By the way, I've also helped and continue to help many people on here with issues. Not to mention spending time to write guides and such (eg. the four in my sig). But thanks anyways.
     
    Last edited by a moderator: Feb 9, 2015
  15. gagipro

    gagipro Registered

    Joined:
    Feb 26, 2013
    Messages:
    473
    Likes Received:
    7
    Multithreaded would be interesting if AI were not following a line... There's no point in coding threads for virtual AIs...
    When there are many choices/paths like in FPS yes it can be a good idea...
     
  16. Spinelli

    Spinelli Banned

    Joined:
    Jan 28, 2012
    Messages:
    5,290
    Likes Received:
    32
    I agree, John. Software, like anything, keeps evolving. People are finding more and better ways to take advantage of multiple threads in games, and with the new consoles, I'm guessing that the rate of progression will only continue to increase.

    Just like how more and more games became dual-threaded instead of single, and then quad-threaded instead of dual, and on and on.
     
  17. Dalek

    Dalek Registered

    Joined:
    Apr 15, 2014
    Messages:
    39
    Likes Received:
    0
    @John,

    Indeed the time factor was one i didnt think of. I have no idea what spec ISI decided for RF2 or the workroute. I guess they did have a plan... Or at least a direction...
    IMO mostlikely something that is evolving due to prioritys...
    I did ask the question, " 3 - there is millions of different PC setups out there, how do you make a system that runs ok on 1 thread but also on 12 ? ", so i'm not blind to it, just a bit in the dark :) .


    @ Spinelli,

    It seems reasonable that before questioning how a software is built, you should have at least some understanding of how it's done. And not just because "the others do it".
    Multithreading is a PITA, and strangely with the research you did on graphics settings in other threads, you seem to have done none here...

    To correct a false statement, my first answer to you, was simply questions.
    If the answers to those questions bother you, then it's your issue.


    You could have found this :

    http://isiforums.net/f/showthread.php/4046-Hyperthreading/page1

    or this :

    http://isiforums.net/f/showthread.php/15141-Multithreading-question

    or even this, they say beginners, it's still hard !

    http://www.codeproject.com/Articles/7953/Thread-Synchronization-for-Beginners


    Have a good read and have a good day !
     
  18. gagipro

    gagipro Registered

    Joined:
    Feb 26, 2013
    Messages:
    473
    Likes Received:
    7
    Multithreading is complex,but would AT-LEAST this be possible (for each AI or...

    Confusion between processor threads (4/8/12) and programming threads (in this case, ever one big thread for AI or a thread for each AI)

    Do you know what is a pthread??

    At least.

    Stupid conversation.

    There's no point of threaded programming for AI!
    AI in rF2 consume nothing! What consumes lot of cpu cycle is the 3D(and physics)!
     
    Last edited by a moderator: Feb 9, 2015
  19. Dalek

    Dalek Registered

    Joined:
    Apr 15, 2014
    Messages:
    39
    Likes Received:
    0
    Thanks gagipro, i learnt something there.
     
  20. MarcG

    MarcG Registered

    Joined:
    Oct 4, 2010
    Messages:
    6,854
    Likes Received:
    2,234
    That doesn't excuse you to talk down to people like you have done in this thread. Be more polite and you'll get more respect with constructive answers.
     
Thread Status:
Not open for further replies.

Share This Page