Comments (1)
Default open comress mode, in compress mode, only first and last histories are saved, others will use diff to generate.
Some rough memory consumption comparism:
in 7950X + 128G, initially 21.6G occupied.
with compress
1-worker, 1 match: ~0.2G
1-worker, 10 match: ~0.2G
16 worker, 10 match: ~0.6G
16 worker, 50 match: ~1.3G, after worker closed ~0.5G
16 worker 100 match: ~1.8G
without compress
16 worker 10 match: ~2.7G, after worker closed ~1.4G
16 worker 50 match: ~7.9G, after worker closed ~5.6G
test codes:
import logging
import multiprocessing
from typing import Literal
from lpsim.server.match import Match
from lpsim.utils import BaseModel
from lpsim.server.deck import Deck
from lpsim.agents import RandomAgent
class Main(BaseModel):
"""
"""
version: str = '1.0.0'
name: Literal['GITCG'] = 'GITCG'
match: Match = Match()
def ttt(args):
logging.basicConfig(level = logging.WARNING)
agent_0 = RandomAgent(player_idx = 0)
agent_1 = RandomAgent(player_idx = 1)
main = Main()
deck = Deck.from_str(
'''
default_version:4.1
charactor:Rhodeia of Loch
charactor:Kamisato Ayaka
charactor:Yaoyao
Traveler's Handy Sword*5
Gambler's Earrings*5
Kanten Senmyou Blessing*5
Sweet Madame*5
Abyssal Summons*5
Fatui Conspiracy*5
Timmie*5
'''
)
main.match.set_deck([deck, deck])
main.match.config.max_same_card_number = 30
main.match.config.history_level = 10
main.match.config.check_deck_restriction = False
main.match.config.initial_hand_size = 20
main.match.config.max_hand_size = 30
main.match.config.card_number = None
##### remove comment to test non-compress
# main.match.config.compress_history = False
assert main.match.start()[0]
main.match.step()
while main.match.round_number < 100 and not main.match.is_game_end():
if len(main.match._history_diff) > 400:
break
if main.match.need_respond(0):
current_agent = agent_0
elif main.match.need_respond(1):
current_agent = agent_1
else:
raise RuntimeError('no agent need to respond')
resp = current_agent.generate_response(main.match)
assert resp is not None
main.match.respond(resp)
main.match.step()
print('game end, save to logs.txt')
return main.match
if __name__ == '__main__':
pool = multiprocessing.Pool(16)
data = pool.imap(ttt, [None] * 50)
res = []
for d in data:
# input()
res.append(d)
...
pool.close()
pool.join()
print('done')
input()
from backend.
Related Issues (20)
- Refactor `class_registry`
- Fix `noqa: F401`
- Replace `numpy.RandomState` with `random.Random`
- Refactor of `instance_factory`
- Update version 4.4 deck code
- Object order in triggering events
- Prepare skill will not trigger "After use skill" "After triggering element reaction by skill"
- New EventFrame structure HOT 1
- Pydantic V2 HOT 1
- Universal object query function HOT 3
- Damage events refactor
- Add version hint in HTTPServer HOT 1
- Sunyata's Flowers can generate two same support cards.
- Multi-processing AB search
- `Blessing of the Divine Relic's Installation` should not reset counter of `Veteran's Visage`, `Ocean-Hued Clam` HOT 1
- Unify revive action
- Option to catch errors on object events so errors on custom cards will not raise error
- Support hot-fix
- Plunging Attack but be frozen, cannot attack
- Shield be removed by other reasons should trigger effect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backend.