+
+
+### 4. Integrate Bot into the Game Loop
+
+After initialization, the player.isBot() method allows you to check
+if a player is a bot or a human player. You can use this information to
+integrate your bot's actions within the game loop, ensuring that it interacts
+with the game environment as intended.
+
+```js
+players = []
+
+onPlayerJoin(async (player) => {
+ // Custom logic for handling player join events.
+
+ // Appending player to players array in order to access it within gameloop
+ players.push(player);
+});
+
+function gameLoop() {
+ // Custom Logic
+
+ for (const player in players) {
+ // Custom Logic
+
+ // Bot usage
+ if (player.isBot()) {
+ // Logic to make the bot act within the game loop
+
+ // Sample implementation
+ if (!player.bot.isAlive()) { return }
+
+ const action = player.bot.decideAction()
+ if (action === "ATTACK") {
+ // Attack Logic Here
+ }
+
+ if (action === "MOVE_FORWARD") {
+ // Move Forward Logic Here
+ }
+
+ // Game mechanics
+
+ // Updating the damage taken
+ player.bot.takeDamage(damageAmount)
+ }
+ }
+}
+```
diff --git a/pages/bots/custombot.mdx b/pages/bots/custombot.mdx
deleted file mode 100644
index 1605040..0000000
--- a/pages/bots/custombot.mdx
+++ /dev/null
@@ -1,72 +0,0 @@
-# Custom Bot Integration with Playroom
-## Overview
-In Playroom's SDK, we've provided developers with the flexibility to design and implement bots according to their own game mechanics and requirements. This not only allows for personalization but also ensures that the bot integrates seamlessly with the unique dynamics of each game.
-
-## How Custom Bot Integration Works
-
-### 1. Import and Extend the SDK's Bot Class
-Start by importing the 'Bot' class from the 'playroomkit'
-
-```js
-import { insertCoin, onPlayerJoin, Bot } from 'playroomkit';
-```
-
-Subsequently, extend this base Bot class for your custom bot.
-This class is devoid of any predefined methods; its primary role
-is to ascertain that your custom bot is identified as a Bot type within the SDK.
-
-```js
-class YourCustomBot extends Bot {
- // Implement your custom bot logic and methods here
-}
-```
-
-### 2. Implement Your Custom Bot Logic
-
-You have complete autonomy over the bot's logic and behavior.
-Implement methods, decision-making processes,
-and any other necessary components in your derived class to make
-your bot function according to your game's needs.
-
-### 3. Initialize Your Bot with the SDK
-
-Once your custom bot class is ready, use the insertCoin() method
-provided by the SDK to pass your bot type and its parameters.
-This step allows the SDK to recognize and initialize your custom bot.
-
-```js
-insertCoin({
- ... other parameters,
-
- enableBots: true, // Indicates to the SDK to activate bot functionality
-
- botOptions: {
- botClass: YourCustomBot, // Specifies the custom bot class to be utilized by the SDK
-
- // OPTIONAL: If you want botParams object for the initialization of custom bot class.
- botParams: {
- ... YourCustomBot parameters,
- }
- },
-}).then(() => {
- // Callback or subsequent logic after the bot initialization completes
- ...
-});
-```
-
-### 4. Integrate Bot into the Game Loop
-
-After initialization, the player.isBot() method allows you to check
-if a player is a bot or a human player. You can use this information to
-integrate your bot's actions within the game loop, ensuring that it interacts
-with the game environment as intended.
-
-```js
-if (player.isBot()) {
- // Logic to make the bot act within the game loop
-}
-```
-
-## Conclusion
-Integrating a custom bot with Playroom's SDK offers a level of personalization and control that can significantly enhance gameplay dynamics.
-By following the steps outlined above, you can seamlessly incorporate your custom bots and redefine the player experience.
\ No newline at end of file
From c144244a8f71bda3baa9e94b93b151267a515b15 Mon Sep 17 00:00:00 2001
From: Junaid Zaidi <51705693+junaidzaidi@users.noreply.github.com>
Date: Thu, 5 Oct 2023 21:40:45 -0700
Subject: [PATCH 5/7] in progress
---
pages/bots.mdx | 10 +++++++---
pages/bots/dqnbot.mdx | 16 +++++-----------
public/.DS_Store | Bin 6148 -> 6148 bytes
public/images/add-bot.png | Bin 0 -> 317173 bytes
4 files changed, 12 insertions(+), 14 deletions(-)
create mode 100644 public/images/add-bot.png
diff --git a/pages/bots.mdx b/pages/bots.mdx
index 33235de..b9256c7 100644
--- a/pages/bots.mdx
+++ b/pages/bots.mdx
@@ -1,8 +1,12 @@
-# Introduction to Bot Integration in Playroom
+# Bots in Playroom
-Playroom now lets you add bots to your games. Customize them to fit your game's style and elevate game experience!
+Playroom lets you define bots for your game. These bots act the same as players; have player state, but can hold custom logic to act within the game loop.
-It's time to dive into the specifics. Choose the path that best suits your development needs:
+Once you set up bots, players see a new ๐ค + button which adds bots to their game room.
+
+### Why Should I Use Bots?
+
+Playing with friends is fun but you can't always have your friends around. Having bots in your game increases engagement and retention. Bots can fill empty rooms in your game, or provide a single player experience.
**[Bot](/bots/bot)**: Explore the process of creating your own bot and integrating it to your game's unique mechanics.
diff --git a/pages/bots/dqnbot.mdx b/pages/bots/dqnbot.mdx
index af5c409..672e9c4 100644
--- a/pages/bots/dqnbot.mdx
+++ b/pages/bots/dqnbot.mdx
@@ -14,13 +14,13 @@ import { insertCoin, onPlayerJoin, DQNBaseBot } from 'playroomkit';
```
### 2. Initialization Using insertCoin
-To activate the DQN bot within your game, you'll employ the insertCoin method. Here's a comprehensive breakdown:
+To activate the DQN bot within your game, you'll utilize the insertCoin method. Here's a comprehensive breakdown:
```js
-insertCoin({
+await insertCoin({
... other parameters,
- enableBots: true, // Signals the SDK to activate the DQN bot
+ enableBots: true, // Signals the SDK to activate bot
botOptions: {
botClass: DQNBaseBot, // Specifies the DQN bot class
@@ -41,7 +41,7 @@ insertCoin({
num_hidden_units: 100, // Number of neurons in the hidden layer
}
- // OPTIONAL: If you have pretrained weights or previous training data
+ // OPTIONAL: Initialize with weights if you have pretrained weights or previous training data
weights: {
// Serialized pretrained weights
@@ -57,11 +57,9 @@ insertCoin({
retrieveFromLocalStorage: true
}
- // OPTIONAL: Enable training mode to visualize and interact with the bot's learning process
+ // OPTIONAL: Enable training mode to visualize graph of iteration/rewards.
trainingMode: true
},
-}).then(() => {
- // Callback or subsequent logic after the bot initialization completes
});
```
@@ -84,7 +82,3 @@ if (player.isBot()) {
To train the bot, continually provide rewards based on its actions to refine its decision-making capabilities.
If you wish to use the bot without additional training, simply utilize the DQN bot's decisions without supplying reward feedback.
-
-## Conclusion
-By integrating the DQN bot with Playroom's SDK, game developers can delve into the captivating realm of reinforcement learning.
-Whether you're keen on crafting an intelligent adversary or an adept ally, the DQN bot facilitates a thrilling gaming experience.
\ No newline at end of file
diff --git a/public/.DS_Store b/public/.DS_Store
index 64bd4beb0e3e9033166a64086c03d0c28fbcdf46..de8c0adafbb77045a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