Bots #23

Merged
Simponic merged 4 commits from bots into main 2023-05-29 19:28:27 -04:00
5 changed files with 14 additions and 7 deletions
Showing only changes of commit 6bc70b96f3 - Show all commits

View File

@ -6,6 +6,12 @@ looking for opponents, or in games when it is one's turn.
https://user-images.githubusercontent.com/25559600/221317658-a80046ca-6009-456d-b43c-67d95baa4bf6.mp4
## Bots
As a user, you can create 2 bot accounts at [/bots](https://chessh.linux.usu.edu/bots). These are driven by
webhooks.
For an example bot, see [chessh example bot](https://github.com/Simponic/chessh_bot).
## Usage
### Dependencies

View File

@ -19,7 +19,7 @@ config :chessh, RateLimits,
discord_notification_rate: 30,
discord_notification_rate_ms: 1000,
bot_redrive_rate: 1,
bot_redrive_rate_ms: 60_000
bot_redrive_rate_ms: 30_000
config :chessh, Web,
discord_oauth_login_url: "https://discord.com/api/oauth2/token",

View File

@ -37,7 +37,6 @@ defmodule Chessh.Bot do
bot: %Chessh.Bot{id: bot_id, name: bot_name},
fen: fen,
turn: turn,
last_move: last_move,
status: status,
light_player_id: light_player_id,
dark_player_id: dark_player_id
@ -50,7 +49,6 @@ defmodule Chessh.Bot do
turn: Atom.to_string(turn),
bot_turn:
(is_nil(light_player_id) && turn == :light) || (is_nil(dark_player_id) && turn == :dark),
last_move: last_move,
status: Atom.to_string(status)
}
end

View File

@ -10,10 +10,11 @@ defmodule Chessh.SSH.Client.Game.Renderer do
@tile_width 7
@tile_height 4
@previous_move_background ANSI.light_magenta_background()
@from_select_background ANSI.light_green_background()
@to_select_background ANSI.light_yellow_background()
@in_check_color ANSI.yellow_background()
@previous_move_background ANSI.color_background(208)
@from_select_background ANSI.color_background(105)
@to_select_background ANSI.color_background(177)
@in_check_color ANSI.color_background(197)
@dark_piece_color ANSI.red()
@light_piece_color ANSI.light_cyan()

View File

@ -106,6 +106,8 @@ defmodule Chessh.SSH.Client.SelectBot do
)
|> Repo.insert()
spawn(fn -> Bot.send_update(game |> Repo.preload([:bot])) end)
{Chessh.SSH.Client.Game,
%Chessh.SSH.Client.Game.State{player_session: player_session, color: color, game: game}}