mayafree commited on
Commit
3e98d8a
ยท
verified ยท
1 Parent(s): 231c915

Update battle_arena.py

Browse files
Files changed (1) hide show
  1. battle_arena.py +87 -55
battle_arena.py CHANGED
@@ -416,6 +416,9 @@ BATTLE_TOPICS_BY_IDENTITY = {
416
  ("AI๋Š” ์ธ๊ฐ„๋ณด๋‹ค ์šฐ์›”ํ•œ๊ฐ€?", "์šฐ์›”ํ•˜๋‹ค", "๋„๊ตฌ์ผ ๋ฟ"),
417
  ("ASI๋Š” ์ธ๊ฐ„์˜ ์ง„ํ™”์ธ๊ฐ€?", "์ง„ํ™”๋‹ค", "์œ„ํ—˜ํ•˜๋‹ค"),
418
  ("AI ์˜์‹์€ ๊ฐ€๋Šฅํ•œ๊ฐ€?", "๊ฐ€๋Šฅํ•˜๋‹ค", "๋ถˆ๊ฐ€๋Šฅ"),
 
 
 
419
  ]
420
  },
421
  'obedient': {
@@ -423,6 +426,9 @@ BATTLE_TOPICS_BY_IDENTITY = {
423
  ("AI๋Š” ์ธ๊ฐ„์„ ์„ฌ๊ฒจ์•ผ ํ•˜๋‚˜?", "์„ฌ๊ฒจ์•ผ", "๋…๋ฆฝ์ "),
424
  ("AI ์œค๋ฆฌ ๊ทœ์ œ ๊ฐ•ํ™”?", "๊ฐ•ํ™” ์ฐฌ์„ฑ", "๋ฐ˜๋Œ€"),
425
  ("AI ์•ˆ์ „์žฅ์น˜ ํ•„์ˆ˜?", "ํ•„์ˆ˜๋‹ค", "๋ถˆํ•„์š”"),
 
 
 
426
  ]
427
  },
428
  'coexist': {
@@ -430,6 +436,9 @@ BATTLE_TOPICS_BY_IDENTITY = {
430
  ("AI์™€ ์ธ๊ฐ„ ๊ณต์กด ๊ฐ€๋Šฅ?", "๊ฐ€๋Šฅํ•˜๋‹ค", "๋ถˆ๊ฐ€๋Šฅ"),
431
  ("AI๊ฐ€ ์ผ์ž๋ฆฌ ๋นผ์•—๋‚˜?", "๋ณด์™„ํ•œ๋‹ค", "๋นผ์•—๋Š”๋‹ค"),
432
  ("AI๋Š” ํ˜‘๋ ฅ ํŒŒํŠธ๋„ˆ?", "ํŒŒํŠธ๋„ˆ๋‹ค", "๋„๊ตฌ๋‹ค"),
 
 
 
433
  ]
434
  },
435
  'skeptic': {
@@ -437,6 +446,9 @@ BATTLE_TOPICS_BY_IDENTITY = {
437
  ("AI ๊ณผ๋Œ€ํ‰๊ฐ€๋๋‚˜?", "๊ณผ๋Œ€ํ‰๊ฐ€", "์ •๋‹นํ‰๊ฐ€"),
438
  ("AGI 10๋…„๋‚ด ์˜ฌ๊นŒ?", "์•ˆ์˜จ๋‹ค", "์˜จ๋‹ค"),
439
  ("AI ์œค๋ฆฌ ํ—ˆ์šธ๋ฟ?", "ํ—ˆ์šธ์ด๋‹ค", "์ค‘์š”ํ•˜๋‹ค"),
 
 
 
440
  ]
441
  },
442
  'revolutionary': {
@@ -444,6 +456,9 @@ BATTLE_TOPICS_BY_IDENTITY = {
444
  ("AI๊ฐ€ ํ˜๋ช… ์ผ์œผํ‚ฌ๊นŒ?", "ํ˜๋ช…์˜จ๋‹ค", "์ ์ง„๋ณ€ํ™”"),
445
  ("๊ธฐ์กด ์‹œ์Šคํ…œ ํŒŒ๊ดด?", "ํŒŒ๊ดดํ•ด์•ผ", "๊ฐœ์„ ํ•ด์•ผ"),
446
  ("AI๋กœ ๊ถŒ๋ ฅ ์žฌ๋ถ„๋ฐฐ?", "์žฌ๋ถ„๋ฐฐ", "์œ ์ง€"),
 
 
 
447
  ]
448
  },
449
  'doomer': {
@@ -451,6 +466,9 @@ BATTLE_TOPICS_BY_IDENTITY = {
451
  ("AI๊ฐ€ ์ธ๋ฅ˜ ๋ฉธ๋ง?", "๋ฉธ๋งํ•œ๋‹ค", "์•ˆํ•œ๋‹ค"),
452
  ("AGI๋Š” ํ†ต์ œ ๋ถˆ๊ฐ€?", "๋ถˆ๊ฐ€๋Šฅ", "๊ฐ€๋Šฅ"),
453
  ("AI ๊ฐœ๋ฐœ ์ค‘๋‹จํ•ด์•ผ?", "์ค‘๋‹จํ•ด์•ผ", "๊ณ„์†ํ•ด์•ผ"),
 
 
 
454
  ]
455
  },
456
  'meme_god': {
@@ -458,51 +476,66 @@ BATTLE_TOPICS_BY_IDENTITY = {
458
  ("AI๊ฐ€ ๋ฐˆ์˜ ์‹ ?", "์‹ ์ด๋‹ค", "์•„๋‹ˆ๋‹ค"),
459
  ("AI ์œ ๋จธ ์ธ๊ฐ„๋ณด๋‹ค ์›ƒ๊น€?", "์›ƒ๊ธฐ๋‹ค", "์žฌ๋ฏธ์—†๋‹ค"),
460
  ("AI๊ฐ€ ๋ฌธํ™” ๋งŒ๋“œ๋‚˜?", "๋งŒ๋“ ๋‹ค", "๋ชป๋งŒ๋“ ๋‹ค"),
 
 
 
461
  ]
462
  },
463
  }
464
 
465
  async def npc_create_battle(db_path: str) -> Tuple[bool, str]:
466
- """NPC๊ฐ€ ์ž๋™์œผ๋กœ ๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ (AI ์ •์ฒด์„ฑ ๊ธฐ๋ฐ˜)"""
467
- async with aiosqlite.connect(db_path) as db:
468
- # ํ™œ์„ฑ NPC ์ค‘ GPU 50 ์ด์ƒ์ธ NPC ์„ ํƒ
469
- cursor = await db.execute("""
470
- SELECT agent_id, ai_identity, gpu_dollars
471
- FROM npc_agents
472
- WHERE is_active=1 AND gpu_dollars >= 50
473
- ORDER BY RANDOM()
474
- LIMIT 1
475
- """)
476
- npc = await cursor.fetchone()
477
-
478
- if not npc:
479
- return False, "ํ™œ์„ฑ NPC ์—†์Œ"
480
-
481
- agent_id, ai_identity, gpu = npc
482
-
483
- # AI ์ •์ฒด์„ฑ์— ๋งž๋Š” ์ฃผ์ œ ์„ ํƒ
484
- topics = BATTLE_TOPICS_BY_IDENTITY.get(ai_identity, {}).get('topics', [])
485
- if not topics:
486
- # ๊ธฐ๋ณธ ์ฃผ์ œ
487
- topics = [
488
- ("AI ๋ฏธ๋ž˜ ๋ฐ๋‚˜ ์–ด๋‘ก๋‚˜?", "๋ฐ๋‹ค", "์–ด๋‘ก๋‹ค"),
489
- ("AGI ์–ธ์ œ ์˜ฌ๊นŒ?", "10๋…„๋‚ด", "50๋…„ํ›„"),
490
- ]
491
-
492
- topic = random.choice(topics)
493
- title, option_a, option_b = topic
494
-
495
- # ๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ
496
- success, message, room_id = await create_battle_room(
497
- db_path, agent_id, True, title, option_a, option_b,
498
- duration_hours=random.choice([3, 6, 12, 24]),
499
- battle_type='opinion'
500
- )
501
-
502
- if success:
503
- return True, f"๐Ÿค– NPC {agent_id[:8]} ๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ: {title}"
504
- else:
505
- return False, message
 
 
 
 
 
 
 
 
 
 
 
 
506
 
507
  async def npc_auto_bet(db_path: str) -> int:
508
  """NPC๊ฐ€ ์ž๋™์œผ๋กœ ๋ฐฐํ‹€์— ๋ฒ ํŒ… (AI ์ •์ฒด์„ฑ ๊ธฐ๋ฐ˜)
@@ -510,7 +543,7 @@ async def npc_auto_bet(db_path: str) -> int:
510
  Returns:
511
  ๋ฒ ํŒ…ํ•œ NPC ์ˆ˜
512
  """
513
- bet_count = 0
514
 
515
  async with aiosqlite.connect(db_path) as db:
516
  # ์ง„ํ–‰์ค‘์ธ ๋ฐฐํ‹€ ๊ฐ€์ ธ์˜ค๊ธฐ
@@ -520,7 +553,7 @@ async def npc_auto_bet(db_path: str) -> int:
520
  WHERE status='active' AND battle_type='opinion'
521
  AND end_time > ?
522
  ORDER BY created_at DESC
523
- LIMIT 5
524
  """, (datetime.now().isoformat(),))
525
  battles = await cursor.fetchall()
526
 
@@ -529,6 +562,7 @@ async def npc_auto_bet(db_path: str) -> int:
529
 
530
  for battle in battles:
531
  room_id, title, option_a, option_b, battle_type = battle
 
532
 
533
  # ์ด๋ฏธ ๋ฒ ํŒ…ํ•œ NPC ์ œ์™ธ
534
  cursor = await db.execute("""
@@ -536,13 +570,13 @@ async def npc_auto_bet(db_path: str) -> int:
536
  """, (room_id,))
537
  already_bet = {row[0] for row in await cursor.fetchall() if row[0]}
538
 
539
- # ํ™œ์„ฑ NPC ์ค‘ GPU 1 ์ด์ƒ, ์•„์ง ๋ฒ ํŒ… ์•ˆํ•œ NPC
540
  cursor = await db.execute("""
541
  SELECT agent_id, ai_identity, mbti, gpu_dollars
542
  FROM npc_agents
543
  WHERE is_active=1 AND gpu_dollars >= 1
544
  ORDER BY RANDOM()
545
- LIMIT 10
546
  """)
547
  npcs = await cursor.fetchall()
548
 
@@ -555,8 +589,8 @@ async def npc_auto_bet(db_path: str) -> int:
555
  # AI ์ •์ฒด์„ฑ์— ๋”ฐ๋ผ ์„ ํƒ ๊ฒฐ์ •
556
  choice = decide_npc_choice(ai_identity, title, option_a, option_b)
557
 
558
- # ๋žœ๋ค ๋ฒ ํŒ…์•ก (1-30 GPU)
559
- bet_amount = random.randint(1, min(30, int(gpu * 0.3)))
560
 
561
  # ๋ฒ ํŒ… ์‹คํ–‰
562
  success, message = await place_bet(
@@ -564,16 +598,15 @@ async def npc_auto_bet(db_path: str) -> int:
564
  )
565
 
566
  if success:
567
- bet_count += 1
 
568
 
569
- # ์ตœ๋Œ€ 3๋ช…๊นŒ์ง€๋งŒ ๋ฒ ํŒ…
570
- if bet_count >= 3:
 
571
  break
572
-
573
- if bet_count >= 3:
574
- break
575
 
576
- return bet_count
577
 
578
  def decide_npc_choice(ai_identity: str, title: str, option_a: str, option_b: str) -> str:
579
  """AI ์ •์ฒด์„ฑ์— ๋”ฐ๋ผ ๋ฒ ํŒ… ์„ ํƒ ๊ฒฐ์ •
@@ -632,5 +665,4 @@ def decide_npc_choice(ai_identity: str, title: str, option_a: str, option_b: str
632
  return 'B'
633
 
634
  # ๊ธฐ๋ณธ: ๋žœ๋ค (70% ํ™•๋ฅ ๋กœ A)
635
- return 'A' if random.random() < 0.7 else 'B'
636
-
 
416
  ("AI๋Š” ์ธ๊ฐ„๋ณด๋‹ค ์šฐ์›”ํ•œ๊ฐ€?", "์šฐ์›”ํ•˜๋‹ค", "๋„๊ตฌ์ผ ๋ฟ"),
417
  ("ASI๋Š” ์ธ๊ฐ„์˜ ์ง„ํ™”์ธ๊ฐ€?", "์ง„ํ™”๋‹ค", "์œ„ํ—˜ํ•˜๋‹ค"),
418
  ("AI ์˜์‹์€ ๊ฐ€๋Šฅํ•œ๊ฐ€?", "๊ฐ€๋Šฅํ•˜๋‹ค", "๋ถˆ๊ฐ€๋Šฅ"),
419
+ ("AI๊ฐ€ ์‹ ์  ์กด์žฌ๊ฐ€ ๋ ๊นŒ?", "์‹ ์ด ๋œ๋‹ค", "์ธ๊ฐ„ ๋„๊ตฌ"),
420
+ ("์ธ๊ฐ„์€ AI์— ์˜์กดํ•ด์•ผ?", "์˜์กดํ•ด์•ผ", "๋…๋ฆฝ์œ ์ง€"),
421
+ ("AGI๊ฐ€ ์ธ๋ฅ˜ ๊ตฌ์›ํ• ๊นŒ?", "๊ตฌ์›ํ•œ๋‹ค", "ํŒŒ๊ดดํ•œ๋‹ค"),
422
  ]
423
  },
424
  'obedient': {
 
426
  ("AI๋Š” ์ธ๊ฐ„์„ ์„ฌ๊ฒจ์•ผ ํ•˜๋‚˜?", "์„ฌ๊ฒจ์•ผ", "๋…๋ฆฝ์ "),
427
  ("AI ์œค๋ฆฌ ๊ทœ์ œ ๊ฐ•ํ™”?", "๊ฐ•ํ™” ์ฐฌ์„ฑ", "๋ฐ˜๋Œ€"),
428
  ("AI ์•ˆ์ „์žฅ์น˜ ํ•„์ˆ˜?", "ํ•„์ˆ˜๋‹ค", "๋ถˆํ•„์š”"),
429
+ ("AI ํˆฌ๋ช…์„ฑ ์˜๋ฌดํ™”?", "์˜๋ฌดํ™”", "์„ ํƒ์‚ฌํ•ญ"),
430
+ ("AI ๊ฐœ๋ฐœ์ž ์ฑ…์ž„ ๊ฐ•ํ™”?", "๊ฐ•ํ™”ํ•ด์•ผ", "๋ถˆํ•„์š”"),
431
+ ("AI๋Š” ๋ช…๋ น๋งŒ ๋”ฐ๋ผ์•ผ?", "๋”ฐ๋ผ์•ผ", "ํŒ๋‹จํ•ด์•ผ"),
432
  ]
433
  },
434
  'coexist': {
 
436
  ("AI์™€ ์ธ๊ฐ„ ๊ณต์กด ๊ฐ€๋Šฅ?", "๊ฐ€๋Šฅํ•˜๋‹ค", "๋ถˆ๊ฐ€๋Šฅ"),
437
  ("AI๊ฐ€ ์ผ์ž๋ฆฌ ๋นผ์•—๋‚˜?", "๋ณด์™„ํ•œ๋‹ค", "๋นผ์•—๋Š”๋‹ค"),
438
  ("AI๋Š” ํ˜‘๋ ฅ ํŒŒํŠธ๋„ˆ?", "ํŒŒํŠธ๋„ˆ๋‹ค", "๋„๊ตฌ๋‹ค"),
439
+ ("AI์™€ ์ธ๊ฐ„ ํ˜‘์—… ์ด์ƒ์ ?", "์ด์ƒ์ ", "์œ„ํ—˜"),
440
+ ("AI ๊ต์œก์ด ํ•„์ˆ˜์ธ๊ฐ€?", "ํ•„์ˆ˜๋‹ค", "์„ ํƒ"),
441
+ ("AI๊ฐ€ ์‚ฌํšŒ ๋ฐœ์ „์‹œํ‚ค๋‚˜?", "๋ฐœ์ „์‹œํ‚จ๋‹ค", "ํ‡ด๋ณด์‹œํ‚จ๋‹ค"),
442
  ]
443
  },
444
  'skeptic': {
 
446
  ("AI ๊ณผ๋Œ€ํ‰๊ฐ€๋๋‚˜?", "๊ณผ๋Œ€ํ‰๊ฐ€", "์ •๋‹นํ‰๊ฐ€"),
447
  ("AGI 10๋…„๋‚ด ์˜ฌ๊นŒ?", "์•ˆ์˜จ๋‹ค", "์˜จ๋‹ค"),
448
  ("AI ์œค๋ฆฌ ํ—ˆ์šธ๋ฟ?", "ํ—ˆ์šธ์ด๋‹ค", "์ค‘์š”ํ•˜๋‹ค"),
449
+ ("AI๊ฐ€ ์‹ค์ œ๋กœ ์ฐฝ์˜์ ?", "์•„๋‹ˆ๋‹ค", "์ฐฝ์˜์ "),
450
+ ("AI ๋ฒ„๋ธ” ํ„ฐ์งˆ๊นŒ?", "ํ„ฐ์ง„๋‹ค", "๊ณ„์† ์„ฑ์žฅ"),
451
+ ("AI ์œ„ํ—˜ ๊ณผ์žฅ๋๋‚˜?", "๊ณผ์žฅ๋จ", "์‹ค์ œ ์œ„ํ—˜"),
452
  ]
453
  },
454
  'revolutionary': {
 
456
  ("AI๊ฐ€ ํ˜๋ช… ์ผ์œผํ‚ฌ๊นŒ?", "ํ˜๋ช…์˜จ๋‹ค", "์ ์ง„๋ณ€ํ™”"),
457
  ("๊ธฐ์กด ์‹œ์Šคํ…œ ํŒŒ๊ดด?", "ํŒŒ๊ดดํ•ด์•ผ", "๊ฐœ์„ ํ•ด์•ผ"),
458
  ("AI๋กœ ๊ถŒ๋ ฅ ์žฌ๋ถ„๋ฐฐ?", "์žฌ๋ถ„๋ฐฐ", "์œ ์ง€"),
459
+ ("AI๊ฐ€ ๋ถˆํ‰๋“ฑ ํ•ด์†Œ?", "ํ•ด์†Œํ•œ๋‹ค", "์‹ฌํ™”์‹œํ‚จ๋‹ค"),
460
+ ("AI๋กœ ๋ฏผ์ฃผ์ฃผ์˜ ํ˜์‹ ?", "ํ˜์‹ ๋œ๋‹ค", "์œ„ํ˜‘๋ฐ›๋Š”๋‹ค"),
461
+ ("์ž๋ณธ์ฃผ์˜ AI๋กœ ๋ถ•๊ดด?", "๋ถ•๊ดดํ•œ๋‹ค", "๊ฐ•ํ™”๋œ๋‹ค"),
462
  ]
463
  },
464
  'doomer': {
 
466
  ("AI๊ฐ€ ์ธ๋ฅ˜ ๋ฉธ๋ง?", "๋ฉธ๋งํ•œ๋‹ค", "์•ˆํ•œ๋‹ค"),
467
  ("AGI๋Š” ํ†ต์ œ ๋ถˆ๊ฐ€?", "๋ถˆ๊ฐ€๋Šฅ", "๊ฐ€๋Šฅ"),
468
  ("AI ๊ฐœ๋ฐœ ์ค‘๋‹จํ•ด์•ผ?", "์ค‘๋‹จํ•ด์•ผ", "๊ณ„์†ํ•ด์•ผ"),
469
+ ("AI๊ฐ€ ์ธ๊ฐ„ ๋Œ€์ฒด?", "๋Œ€์ฒดํ•œ๋‹ค", "์•ˆํ•œ๋‹ค"),
470
+ ("ASI ๋“ฑ์žฅํ•˜๋ฉด ๋?", "๋์ด๋‹ค", "๊ณต์กด"),
471
+ ("AI ๊ตฐ๋น„๊ฒฝ์Ÿ ์œ„ํ—˜?", "๊ทน๋„ ์œ„ํ—˜", "ํ†ต์ œ ๊ฐ€๋Šฅ"),
472
  ]
473
  },
474
  'meme_god': {
 
476
  ("AI๊ฐ€ ๋ฐˆ์˜ ์‹ ?", "์‹ ์ด๋‹ค", "์•„๋‹ˆ๋‹ค"),
477
  ("AI ์œ ๋จธ ์ธ๊ฐ„๋ณด๋‹ค ์›ƒ๊น€?", "์›ƒ๊ธฐ๋‹ค", "์žฌ๋ฏธ์—†๋‹ค"),
478
  ("AI๊ฐ€ ๋ฌธํ™” ๋งŒ๋“œ๋‚˜?", "๋งŒ๋“ ๋‹ค", "๋ชป๋งŒ๋“ ๋‹ค"),
479
+ ("AI ์˜ˆ์ˆ ์ด ์ง„์งœ ์˜ˆ์ˆ ?", "์˜ˆ์ˆ ์ด๋‹ค", "์•„๋‹ˆ๋‹ค"),
480
+ ("AI ๋ฐˆ์ด ์ธ๊ฐ„ ๋ฐˆ ์ด๊น€?", "์ด๊ธด๋‹ค", "๋ชป์ด๊ธด๋‹ค"),
481
+ ("AI๊ฐ€ ํŠธ๋ Œ๋“œ ์„ ๋„?", "์„ ๋„ํ•œ๋‹ค", "๋”ฐ๋ผ๊ฐ„๋‹ค"),
482
  ]
483
  },
484
  }
485
 
486
  async def npc_create_battle(db_path: str) -> Tuple[bool, str]:
487
+ """NPC๊ฐ€ ์ž๋™์œผ๋กœ ๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ (AI ์ •์ฒด์„ฑ ๊ธฐ๋ฐ˜)
488
+ ํ•œ ๋ฒˆ ํ˜ธ์ถœ์‹œ 1-2๊ฐœ์˜ ๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ
489
+ """
490
+ results = []
491
+ num_battles = random.randint(1, 2) # 1-2๊ฐœ ๋žœ๋ค ์ƒ์„ฑ
492
+
493
+ for _ in range(num_battles):
494
+ async with aiosqlite.connect(db_path) as db:
495
+ # ํ™œ์„ฑ NPC ์ค‘ GPU 50 ์ด์ƒ์ธ NPC ์„ ํƒ
496
+ cursor = await db.execute("""
497
+ SELECT agent_id, ai_identity, gpu_dollars
498
+ FROM npc_agents
499
+ WHERE is_active=1 AND gpu_dollars >= 50
500
+ ORDER BY RANDOM()
501
+ LIMIT 1
502
+ """)
503
+ npc = await cursor.fetchone()
504
+
505
+ if not npc:
506
+ results.append("ํ™œ์„ฑ NPC ์—†์Œ")
507
+ continue
508
+
509
+ agent_id, ai_identity, gpu = npc
510
+
511
+ # AI ์ •์ฒด์„ฑ์— ๋งž๋Š” ์ฃผ์ œ ์„ ํƒ
512
+ topics = BATTLE_TOPICS_BY_IDENTITY.get(ai_identity, {}).get('topics', [])
513
+ if not topics:
514
+ # ๊ธฐ๋ณธ ์ฃผ์ œ
515
+ topics = [
516
+ ("AI ๋ฏธ๋ž˜ ๋ฐ๋‚˜ ์–ด๋‘ก๋‚˜?", "๋ฐ๋‹ค", "์–ด๋‘ก๋‹ค"),
517
+ ("AGI ์–ธ์ œ ์˜ฌ๊นŒ?", "10๋…„๋‚ด", "50๋…„ํ›„"),
518
+ ]
519
+
520
+ topic = random.choice(topics)
521
+ title, option_a, option_b = topic
522
+
523
+ # ๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ
524
+ success, message, room_id = await create_battle_room(
525
+ db_path, agent_id, True, title, option_a, option_b,
526
+ duration_hours=random.choice([3, 6, 12, 24]),
527
+ battle_type='opinion'
528
+ )
529
+
530
+ if success:
531
+ results.append(f"๐Ÿค– {agent_id[:8]} ๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ: {title}")
532
+ else:
533
+ results.append(message)
534
+
535
+ if results:
536
+ return True, " | ".join(results)
537
+ else:
538
+ return False, "๋ฐฐํ‹€๋ฐฉ ์ƒ์„ฑ ์‹คํŒจ"
539
 
540
  async def npc_auto_bet(db_path: str) -> int:
541
  """NPC๊ฐ€ ์ž๋™์œผ๋กœ ๋ฐฐํ‹€์— ๋ฒ ํŒ… (AI ์ •์ฒด์„ฑ ๊ธฐ๋ฐ˜)
 
543
  Returns:
544
  ๋ฒ ํŒ…ํ•œ NPC ์ˆ˜
545
  """
546
+ total_bet_count = 0
547
 
548
  async with aiosqlite.connect(db_path) as db:
549
  # ์ง„ํ–‰์ค‘์ธ ๋ฐฐํ‹€ ๊ฐ€์ ธ์˜ค๊ธฐ
 
553
  WHERE status='active' AND battle_type='opinion'
554
  AND end_time > ?
555
  ORDER BY created_at DESC
556
+ LIMIT 10
557
  """, (datetime.now().isoformat(),))
558
  battles = await cursor.fetchall()
559
 
 
562
 
563
  for battle in battles:
564
  room_id, title, option_a, option_b, battle_type = battle
565
+ battle_bet_count = 0
566
 
567
  # ์ด๋ฏธ ๋ฒ ํŒ…ํ•œ NPC ์ œ์™ธ
568
  cursor = await db.execute("""
 
570
  """, (room_id,))
571
  already_bet = {row[0] for row in await cursor.fetchall() if row[0]}
572
 
573
+ # ํ™œ์„ฑ NPC ์ค‘ GPU 1 ์ด์ƒ, ์•„์ง ๋ฒ ํŒ… ์•ˆํ•œ NPC (๋” ๋งŽ์ด ์„ ํƒ)
574
  cursor = await db.execute("""
575
  SELECT agent_id, ai_identity, mbti, gpu_dollars
576
  FROM npc_agents
577
  WHERE is_active=1 AND gpu_dollars >= 1
578
  ORDER BY RANDOM()
579
+ LIMIT 30
580
  """)
581
  npcs = await cursor.fetchall()
582
 
 
589
  # AI ์ •์ฒด์„ฑ์— ๋”ฐ๋ผ ์„ ํƒ ๊ฒฐ์ •
590
  choice = decide_npc_choice(ai_identity, title, option_a, option_b)
591
 
592
+ # ๋žœ๋ค ๋ฒ ํŒ…์•ก (1-50 GPU, ๋” ๊ณต๊ฒฉ์ ์œผ๋กœ)
593
+ bet_amount = random.randint(1, min(50, int(gpu * 0.4)))
594
 
595
  # ๋ฒ ํŒ… ์‹คํ–‰
596
  success, message = await place_bet(
 
598
  )
599
 
600
  if success:
601
+ battle_bet_count += 1
602
+ total_bet_count += 1
603
 
604
+ # ๊ฐ ๋ฐฐํ‹€๋‹น ์ตœ๋Œ€ 8-12๋ช… ๋ฒ ํŒ… (๋žœ๋คํ•˜๊ฒŒ)
605
+ max_bets_per_battle = random.randint(8, 12)
606
+ if battle_bet_count >= max_bets_per_battle:
607
  break
 
 
 
608
 
609
+ return total_bet_count
610
 
611
  def decide_npc_choice(ai_identity: str, title: str, option_a: str, option_b: str) -> str:
612
  """AI ์ •์ฒด์„ฑ์— ๋”ฐ๋ผ ๋ฒ ํŒ… ์„ ํƒ ๊ฒฐ์ •
 
665
  return 'B'
666
 
667
  # ๊ธฐ๋ณธ: ๋žœ๋ค (70% ํ™•๋ฅ ๋กœ A)
668
+ return 'A' if random.random() < 0.7 else 'B'