歐陸風雲4開發日誌 | 2/19 神奇位數在哪裡

2021-03-05 牧遊社

牧遊社 牧有漢化翻譯

 

EU4 - Development Diary - 19th of February 2019

Duplo, Rookie GameDev

 

Fantastic bits and where to find them

神奇位數在哪裡

 

Hi everyone, I am Lorenzo aka Duplo aka The Battlepope aka The Caped Crusader and I am programmer on our beloved Europa Universalis 4. You may have seen me in the Dharma Dev Clash, struggling to spread Catholicism and occasionally getting betrayed by fellow Italians and wrecked up by Venice AI. 

大家吼啊,本人Lorenzo,別名Duplo,外號The Battlepope,暱稱The Caped Crusader又回來了。我也是我們廣受愛戴的歐陸風雲4開發組的一名程序猿。你可能在達摩的開發人員大戰直播中見到過我遊玩教宗國,費盡心思擴大天主恩澤之地,卻間歇性被義大利二五仔背叛,持續性被威尼斯AI吊打的經歷。

 

In these last weeks we announced that 1.28.3 was the last Europa Universalis 4 release supporting 32-bit, since we are moving toward 64-bit. I thought it would be nice to give to all of you an insight of what this means, what to genuinely expect in the near future and what to definitely not expect.

在前幾周中,鑑於我們要向64位邁進,我們發布了最後一個支持32位系統的歐陸風雲版本號1.28.3。我尋思應該向全體玩家介紹這項工作的意義,讓大家知道在近期內要期待哪些玩意而哪些東西是不切實際的,這總歸是件好事。

 

There's been a lot of fuss about 64 vs 32-bit apps lately. But what is all of this about?

最近經常有很多關於64位和32位程序的爭論,但到底啥是位數?

 

It is no mystery that Apple decided to deprecate 32-bit apps in MacOS 10.14 "Mojave" (2018) in order to drop the support completely in the future: they are doing an amazing job reminding us about this every time we launch Steam or our beloved Europa Universalis 4.

蘋果公司在2018年發布的MacOS 10.14「莫哈維」系統中,已經決定不鼓勵使用32位應用程式,以此在未來完全停掉對其的維護,這已經不是什麼秘密了。每次我們啟動Steam或親愛的歐陸風雲4時,蘋果公司的大手筆都在提醒著我們關注這件事。

 

What may be less known is that while 32-bit apps may still run on the latest MacOS release the new development environment was stripped out of all the fancy 32-bit support, making it painful for the poor developers to even compile the game. They are trying hard to make everyone move to 64. But why?

大眾用戶常常不盡了解的是,儘管此時32位應用程式仍然可以在最新的MacOS系統上運行,但新的開發環境已經去掉了對美好32位系統的支持,這就導致可憐的開發者們陷入了深深的痛苦,更別提編譯遊戲了。

 

If I got your attention so far, we can finally dive into the topic. It's going to be great.

如果從開頭到現在,我的話能引起你的注意,那麼我們終於就可以開始進入話題了,接下來的內容會很棒的。

 

The fellowship of the bits

位數的歷史進程

 

When we say 64-bit, we are talking about x86-64, a CPU architecture designed by AMD of which the specifications were released in the year of our Lord 2000.

當我們說64位的時候,我們在說的實際上是x86-64,它是由AMD公司所設計的CPU架構,其規格在我主耶穌誕辰2000年時發布。

 

In the year 2001, the Linux kernel started supporting this new architecture, even if there were no processors available on the market yet.

2001,Linux kernel作業系統也開始支持這種進行架構,即使當時市場上還沒有這種架構的處理器。

 

In the year 2003, the very first x86-64 processor is released: the AMD64 Opteron. Several Linux distributions were already supporting x86-64.

2003,第一個採用x86-64架構的處理器發布,也就是大名鼎鼎的AMD64皓龍。隨後,幾個支持x86-64的Linux產品也隨之發布。

 

In the year 2005, Microsoft discontinued the IA-64 (another 64-bit architecture from Intel) version of Windows XP, and released Windows XP Professional x64 Edition.

2005,微軟終止了利用IA-64(另一款英特爾的64位架構)開發的Windows XP,發布了正式的Windows XP 64位專業版。

 

In the year 2009, Apple latest state of the of art system, Mac OS X 10.6 "Snow Leopard", was released with full support for 64 bits on the x86-64 platform. Also Windows 7 started to be loaded by default in his 64 bit version on most new computers.

2009,蘋果最新版的系統MacOS X 10.6「雪豹」帶著對x86-64平臺64位的完全支持發布。同時,Windows 7也開始在最新的電腦上默認安裝64位版本

 

In the year 2011, with Mac OS X 10.7 "Lion", Apple decided to drop the support for 32-bit CPUs, effectively starting that modernization process of their platform that last year resulted in the deprecation of 32-bit apps.

2011,隨著Mac OS X 10.7「獅」的發布,蘋果決定停止支持32位CPU,有效開啟了自家平臺現代化的進程,最終導致了去年的對32位應用程式的停止支持。

Nice. But still, why should I care?

幹得漂亮。但是為什麼俺們要在乎這些呢?


Well, there are several reasons to actually move to 64-bit. The looming threat of deprecation on MacOS is maybe the most evident, but there is much more. The x86-64 architecture is better than its older brother, by far.

嗯,實際上轉向64位的確有一些原因。MacOS不支持32位的陰雲或許是最主要的,但還有更多因素在其中。目前為止x86-64架構的確比他的老哥強多了。

 

Without going too much into technical details, the advantages of going full 64-bit can be summarized in three main points:

不討論過多技術細節,全面使用64位的優點可以被概括成以下三點

 

1. Extended addresss pace

1. 擴展了地址空間

64-bit applications can break the hard limit of 4 GB of RAM. By several orders of magnitude. Do you like blobbing in Europa Universalis 4? Think about how happy the CPUs would be if they could do the same with RAM.

64位應用程式可以來打破RAM的4GB固定限制。二者不在一個數量級上。你希望歐陸風雲4中用二進位大對象嗎?想想如果這樣改進的話,CPU在用RAM 做相同的工作時會有多開心。

2. Capacity increase

2. 性能增強

 

64-bit registers and 64-bit enabled operands that will allow the CPU to perform trivially operations that were costly in the 32-bit architecture. Didn’t you want to find your way from Paris to Beijing in the blink of an eye?

同樣是那些在32位中耗費性能的繁瑣操作,64位的寄存器和元運算就可以讓CPU正常運轉。你難道不想在眨眼之間就尋到巴黎到北京的路徑嗎?

3. Larger number of general-purpose registers

3. 更多的通用寄存器

 

In compute-intensive code, the 64-bit compiler will make use of these additional registers to better optimize the generated program. Russia will be able to recruit Streltsy even faster!

在計算密集型的代碼中,64位編譯器將利用這些額外的寄存器來更好地優化生成的程序。俄羅斯將能夠更快地招募射擊軍!

There is also another, non-technical, advantage: support. While Microsoft is not as zealous as Apple in its crusade against legacy technology, they are obviously putting most of their efforts in the new - and definitely more common - architecture. Of course the 32-bit tools are still doing an honest job, but having the chance to move to the new 64-bit ones will allow us to get advantage of the new hardware features, getting less bugs and better performances.

還有另一個,非「技術性」的優勢:技術支持。雖然微軟不是像蘋果那樣狂熱地反對傳統技術,但是他們也更多的致力於更新的以及顯然更常見的架構。當然32位架構下的工具仍然在忠實的履行自己的功能,但是轉移到新的64位架構能夠讓我們利用更多的硬體功能,更少的BUG,與更好的性能。

 

Wow! Great!

吼啊!支持!

 

That said, moving to 64-bits won’t magically make the game run twice as fast, nor it will make more content appear out of nothing. While the migration to the new architecture itself will have little impact on Europa Universalis 4 at the beginning, it will put the foundation for the future development, allowing us - the programmers - to gradually try to squeeze the most out of the CPUs! But important questions first…

也就是說,轉向64位不會神奇地使遊戲運行速度提高兩倍,也不會讓更多內容無中生有。雖然遷移到新架構本身一開始對EU4影響不大,但它將為未來的發展奠定基礎,讓我們的程式設計師逐漸嘗試更充分的利用CPU! 但先談談重要的問題...

 

Multithreading when?

何時多線程?

 

Really? C’mon… The lack of multithreading in Europa Universalis 4 has been a common misconception for a long time.

講真?別搞我們...歐陸風雲4中缺少多線程是一個長期的普遍誤解。

 

What is multithreading about? Multithreading involves taking small pieces of logic and potentially execute them at the same time, getting advantage of the multiple cores of modern CPUs. The advantage of multithreading is that we can squeeze the most of the processor and get things done faster, because executed at the same time. The main problem of multithreading is that it’s impossible to predict when the Operating System is going to let them run, as the execution of threads is completely out of the application control. Working with multithreading is basically finding the proper balance between the potentially better performances given by running tasks at the same time and the performance loss due to the synchronization.

什麼是多線程?多線程涉及採用小塊邏輯並可能同時執行它們,從而充分利用現代CPU的多核心。多線程的優勢在於我們可以擠出儘可能多的處理器並更快地完成任務,得益於它們同時執行任務。多線程的主要問題是無法預測作業系統何時讓它們運行,因為線程的執行完全超出了應用程式控制。使用多線程基本上可以在同時運行任務所帶來的潛在更好性能與同步導致的性能損失之間找到適當的平衡。

 

This trade off isespecially noticeable in Europa Universalis 4 as the game has tons of small pieces of information to calculate, and each of them is heavily influencing the AI behavior.

這種權衡在歐陸風雲4中尤為明顯,因為遊戲中有大量的小塊信息需要計算,而且每一項都會嚴重影響AI的行為。

 

There are things that can be safely executed in parallel - and indeed they are executed that way - like loading and processing data, updating independent pieces of the gamestate, cache calculations, most of AI behaviors… But there are also things that definitely cannot: pieces of gamestate dependent on other pieces to be calculated before and so on... Trying to force those interdependent operations to be executed in parallel would produce non-deterministic results - different results even with exactly the same initial state - and inconsistent data. This non-deterministic behavior can lead to the game crashing, because the data dependent for an operation might be still in an incomplete state.

有些東西可以安全地並行執行,他們也確實已經被並行執行了,比如讀取與處理數據,刷新遊戲狀態中獨立的那些部分、緩存計算、大部分AI行為...但是也有一些部分絕對不能拿來並行處理:那些相互之間不那麼獨立的,需要進行先後計算的遊戲狀態等等讓這些非獨立的操作進行並行處理會產生不確定的狀態:同樣的初始條件會導出不一致乃至矛盾的結果。這種非確定行為可能導致遊戲崩潰,因為操作所依賴數據可能仍處於不完整狀態。

 

A mysterious and shady voice I can hear behind me explains this problem this way:

我能聽到一個神秘而陰暗的聲音以這種方式解釋了這個問題:

Imagine the data as existing as a quantum wave function. Until observed we can not know what state the data is in. When one thread needs to access and change that data the wave function collapses as it's being observed. If there were an expectation of that the data would be in a specific state before the wave function collapses it will just be garbled mess and the universe crashes.

想像一下,數據存在於量子波函數中。在觀察之前,我們無法知道數據處於什麼狀態。當一個線程需要訪問並更改該數據時,波函數會在觀察時崩潰。如果期望在波函數崩潰之前數據將處於特定狀態,那麼就會出現亂碼並且宇宙崩潰。

One of the focus of us, programmers, is to try to get the best performances possible, while adding new cool features. Multithreading is already a powerful tool in our toolbox. Multithreading is a thing in Europa Universalis 4, and it’s here to stay

我們程式設計師的一個焦點是嘗試獲得最佳性能,同時添加新的很酷®的內容。 多線程已經是我們工具箱中的強大工具。多線程已經是歐陸風雲4工具箱中的一個強大工具。EU4是多線程運行的,它就是這麼工作的。

 

This old, but still valid Development Diary is an example of our effort to get the best performances out of our game, and the charts show how multithreading is actually a fundamental part of this effort!

這個先前的但仍然有效的開發日誌是我們努力從遊戲中獲得最佳性能的一個例子,圖表顯示多線程實際上是這項工作的基本部分!

If you have any question, please write them in this thread. I'll follow the discussion and try to answer all of you!

如果您有任何疑問,請在論壇貼中回復。我會跟著討論,試著回答每個人的問題!

 

 

翻譯:坎寧 MatrixEssenes

校對:萬豪頓 三等文官猹中堂

歡迎關注鬥魚主播小牧Phenix

歡迎關注牧遊社微信公眾號和知乎專欄!微信公眾號近期改版為信息流,歡迎置頂訂閱不迷路,即時獲得推送消息!

歡迎加入牧有漢化,致力於為玩家社群提供優質內容!翻譯人員募集中!

相關焦點

  • 【歐陸風雲桌遊】開發日誌#1
    歐陸風雲粉絲們和桌遊愛好者們,大家好!我們很高興能發布歐陸風雲桌遊的第一個開發日誌。我們知道你們中的一些人已經等不及了。
  • 歐陸風雲4開發日誌 | 11/27 黃金世紀的新兵模
    牧遊社 牧有漢化翻譯 EU4 -
  • 歐陸風雲4開發日誌 | 11/5 批量建造與和談改進
    Fitting today's dev diary is on a date like this considering we have the EU4 Lan Party at Moszna castle just around the corner!
  • 歐陸風雲4開發日誌 | 12/3 革命萬歲!
    大家吼啊,新的一篇開發日誌終於又到來了。在過去的數個星期裡我一直都在給你們劇透這篇開發日誌的內容。在寫這篇開發日誌時候我發現了一個bug:革命中心沒有革命,而這顯然是個錯誤。不得不說在這寫這篇開發日誌的時候,任何數據/要求都仍然還在施工當中。同時我還注意到,在我們把這些新內容加進遊戲之後,AI變得比我預想中更加擅長把專制度加滿了,真是意想不到的快樂。The quick and much more fun way is the new Revolution Disaster.
  • 歐陸風雲4開發日誌 | 2/25 僱傭兵團的新改動
    我們已經著手開發此更新很久了,之前的開發日誌已經涵蓋了其中的很多特性。但僅僅因為我們已經講過某些內容,不意味著我們就停止開發這些特性了,我們會繼續打磨並不斷改善它們。今天我們將回過頭來看新僱傭兵機制,並將更加深入。
  • 歐陸風雲4在哪買 歐陸風雲4steam快速購買
    歐陸風雲4是一款策略戰棋遊戲,遊戲在一張地圖上進行同時這張地圖模擬了真實世界。下面小編就為大家介紹歐陸風雲4steam快速購買地址。
  • 歐陸風雲4開發日誌 | 8/14 達摩內容包
    牧遊社 牧有漢化翻譯 EU4-
  • 歐陸風雲4開發日誌 | 1/12 玻里尼西亞
    牧遊社 牧有漢化翻譯 EU4 -
  • 歐陸風雲4:達摩將於9月6日發售
    歐陸風雲4:達摩將於9月6日發行 牧遊社 牧有漢化翻譯 STOCKHOLM - August 14, 2018斯德哥爾摩,2018年8月14日。歐陸風雲4,Paradox Development Studio的經典歷史大戰略遊戲,其最新的拓展包達摩Dharma將專注於展現印度的財富和其政壇的詭譎風雲。你能否領導次大陸抵禦外來貿易帝國的侵略呢?亦或是在這片世界上最富饒的土地之一上建立一個歐洲人的貿易帝國呢?
  • 《歐陸風雲4》皇帝DLC攻略 新增成就一覽
    導 讀 歐陸風雲4皇帝DLC新增成就一覽 發布時間:2020-06-10 14:08 來源:bilibili  作者:興登堡公爵 歐陸風雲4於今日正式發售了皇帝
  • 歐陸風雲4開發日誌 | 6/2 皇帝擴展包補丁日誌(第二部分)
    Development Diary - 2nd of June 2020 (Part-2)Groogy, EU4 Game DesignerHello everyone!It's our longest list of fixes yet ever released for EU4. For comparison Holy Fury changelog is somewhere around ~600 entries.大家好!我們的1.30新版本號發布在即,是時候展示一下我們的更新日誌了。
  • 鋼鐵雄心4開發日誌 | 2/20 炮手就位全面總結
    鋼鐵雄心4開發日誌 | 7/4 天佑吾王:英國國策樹重製鋼鐵雄心4開發日誌 | 11/28 細節內容總覽 Ⅲ 鋼鐵雄心4開發日誌 | 9/19 流亡政府 鋼鐵雄心4開發日誌 | 9/19 流亡政府我們添加了一些新的地圖模式,允許你配置可以快速訪問的地圖模式(非常類似於歐陸4)。
  • 《歐陸風雲4》簡體中文免安裝版
    遊戲介紹《歐陸風雲4》是由Paradox Development Studio製作,Paradox Entertainment於2013
  • 鋼鐵雄心4開發日誌 | 2/28 Recap Episode! 版本重要更新概覽!
    >https://mp.weixin.qq.com/s/-7-9t1ETEm6Z_AebilnuUA鋼鐵雄心4開發日誌 | 11/22 Communist Chinahttps://mp.weixin.qq.com/s/0nIOXDrRsKpyiu6Aqj4Isw鋼鐵雄心4開發日誌 | 12/13
  • 《神奇男孩3:龍之陷阱》最新開發日誌視頻公開!_遊俠網 Ali213.net
    LIzardcube公司和DotEmu工作室最近公布了《神奇男孩3:龍之陷阱(Wonder Boy: The Dragon’s Trap)》開發日誌視頻,主要介紹了本作的藝術風格。
  • Stellaris開發日誌#110 | 4/5 Creation and Beyond
    又輪到我來給大家寫新的日誌了,這篇日誌對於我而言這是非常特別的。如果你還不認識我的話,我叫Björn Iversen,是PDS的音頻總監。有趣的是,自從歐陸風雲I開始我就一直有在接觸PDS開發的遊戲。所以你們就自己想想吧,當我第一次走進辦公室時,毫無防備地發現自己要接手的竟然是PDS的一個新IP,而且還是個科幻遊戲,當時我該有多麼爽到啊!能參與到這樣的遊戲的製作之中就是每個音效師的理想啊!有誰不想做點雷射啊爆炸啊什麼的嗎!
  • 56《歐陸風雲4》遊戲介紹及下載地址
    《歐陸風雲4》是由Paradox Development Studio製作,ParadoxEntertainment於2013年8月13日發行的一款策略遊戲
  • 【遊戲】為什麼歐陸風雲這麼令人上癮?
    為什麼歐陸風雲這麼令人上癮?歐陸風雲4非常讓人上癮。因為任何玩家,無論來自何處,父母、祖先來自何處,都能在歐陸風雲4中找到自己的位置。歐陸風雲4之所以令人上癮,正是因為其複雜性。每個人都能在遊戲中找到與他們相關的東西。這太棒了,你擁有無數的選擇。Hans Bauer跟評:I really want to play EU4 again, now, thanks for that.
  • 「遊戲漫談紀」精羅看了沉默,精明看了流淚,歐陸風雲的獨特魅力
    (精羅暴怒中) Part.1 崇禎和君士坦丁十一世 最初入坑歐陸風雲4是因為什麼來著,好像是因為那個視頻,那本小說,和那本漫畫。 Part.2 新手的噩夢 談起歐陸風雲4,讓大多數人變色的,莫過於那約等於沒有的新手引導系統,當然極差的新手引導是P社的傳統藝能,重要程度不亞於
  • 歐陸風雲4——大明風雲(二)
    《歐陸風雲》4簡單模擬了政治、經濟、文化、軍事、外交等一切歷史存在的元素,遊戲入手還是比較難的。