Code Monkey home page Code Monkey logo

Comments (1)

zyr17 avatar zyr17 commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.