Skip to content

Commit

Permalink
Tzar v1 finish (#7)
Browse files Browse the repository at this point in the history
* test out box drawing characters on all platforms

* draw a grid

* draw it

* a whole bunch of work on hex coordinates and drawing

* feeling better about drawing now

* drawing with new gamestate

* some docs and ids for the units

* add bestline for input handling

* quick little command parser

* move action

* port a bunch of drawing code to raylib

* lots of UI progress and some work on action enumeration

* commit before I break everything redoing it

* I think this is really working the way I want now

* game over check

* clean up comments I don't need

* well I broke the UI :(

* Fix command generation and end turn when there are no more commands.

* random AI turns

* more lag between ai turns so the AI is followable

* only build for some platforms

* roll for volley

* random choice AI

* I actually just lost to it!

* tweaks to hover state and maybe get cl working

* some optimizations and notes

* wip before cursor stuff

* resize

* difficulty setting

* ui tweaks for non hdpi

* getting started on MCTS

* refactor so I can re-use rollout code

* first pass at MCTS

* chance nodes for volleys, but it's still making some very bad moves.

* reuse the tree if we can

* way better now, both easy and medium seem to be working

* mcts isn't that good yet but uniform rollouts feels pretty good.

* commit before redoing the mcts tree

* version with some memory problems

* mcts per turn is working

* mcts wasn't even doing rollouts lol

* well, not quite, need to try dpw next

* double progressive widening, dunno if it's actually better or not

* break ai into steps so it doesn't block the UI

* show thinking time

* more fair now, AIs do the same amount of work and are fast enough per step for the UI

* try to do a build

* v4

* path?

* turn off asan

* don't see doesn't work on windows I guess

* try clang instead

* clean up a bunch

* first version of a web build, had to drop using steve.h because the arena isn't compatible with wasm.

* does that fix the error?

* ignore more stuff

* more of a constant

* so much a constant

* js thoughts

* move to tazar-v1

* set up new tazar project

* set up new tazar project
  • Loading branch information
saolsen authored Feb 15, 2025
1 parent 170f8e6 commit 1df1404
Show file tree
Hide file tree
Showing 18 changed files with 3,118 additions and 1,400 deletions.
61 changes: 35 additions & 26 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ endif ()
# * On MacOS need environment variable set MallocNanoZone=0
# or you'll get a warning with asan in stdlib code.
if ((NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") AND (CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
#target_compile_options(compile-options INTERFACE -fsanitize=address -fno-omit-frame-pointer)
#target_link_options(compile-options INTERFACE -fsanitize=address)
target_compile_options(compile-options INTERFACE -fsanitize=address -fno-omit-frame-pointer)
target_link_options(compile-options INTERFACE -fsanitize=address)
endif ()

enable_testing()
Expand Down Expand Up @@ -50,31 +50,40 @@ if (NOT ((CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_C_COMPILER_ID MATCHES "
endif ()

# Raylib stuff is only working for a few platforms right now.
#if ((NOT ((CMAKE_SYSTEM_NAME STREQUAL "Darwin") AND (CMAKE_C_COMPILER_ID STREQUAL "GNU"))))
# include(FetchContent)
# set(FETCHCONTENT_QUIET FALSE)
# set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
# set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games
# set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
# set(CUSTOMIZE_BUILD OFF CACHE BOOL "" FORCE)
#
# FetchContent_Declare(
# raylib
# GIT_REPOSITORY "https://github.com/raysan5/raylib.git"
# GIT_TAG "master"
# GIT_PROGRESS TRUE
# )
# FetchContent_MakeAvailable(raylib)
#
# #if (EMSCRIPTEN)
# # set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s GL_ENABLE_GET_PROC_ADDRESS=1 -s ALLOW_MEMORY_GROWTH")
# # set(CMAKE_EXECUTABLE_SUFFIX ".html")
# #endif ()
#
# add_executable(tazar-v1 ../tazar-v1/tazar_game.c ../tazar-v1/tazar_ai.c ../tazar-v1/tazar_ui.c ../tazar-v1/tazar_main.c)
# target_link_libraries(tazar-v1 PRIVATE compile-options raylib)
#endif ()

if ((NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (NOT ((CMAKE_SYSTEM_NAME STREQUAL "Darwin") AND (CMAKE_C_COMPILER_ID STREQUAL "GNU"))))
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
set(CUSTOMIZE_BUILD OFF CACHE BOOL "" FORCE)
add_executable(tazar-test ../tazar/tazar_game.c ../tazar/tazar_ai.c ../tazar/tazar_test.c)
target_link_libraries(tazar-test PRIVATE compile-options)

FetchContent_Declare(
raylib
GIT_REPOSITORY "https://github.com/raysan5/raylib.git"
GIT_TAG "master"
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(raylib)

if (EMSCRIPTEN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s GL_ENABLE_GET_PROC_ADDRESS=1 -s ALLOW_MEMORY_GROWTH")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif ()

add_executable(tazar ../tazar/tazar_game.c ../tazar/tazar_ai.c ../tazar/tazar_ui.c ../tazar/tazar_main.c)
target_link_libraries(tazar PRIVATE compile-options raylib)
if (EMSCRIPTEN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH -s EXPORTED_FUNCTIONS=\"['_tazar_ai']\" -s EXPORTED_RUNTIME_METHODS=ccall,cwrap")
add_executable(tazar-wasm ../tazar/tazar_game.c ../tazar/tazar_ai.c ../tazar/tazar_wasm.c)
target_link_libraries(tazar-wasm PRIVATE compile-options)
configure_file(../tazar/index.html index.html COPYONLY)
configure_file(../tazar/tazar.js tazar.js COPYONLY)
endif ()

#add_library(bestline ../3rdparty/bestline/bestline.c)
#target_link_libraries(tazar compile-options bestline)
# new project
12 changes: 12 additions & 0 deletions lab/wasm/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>wasm test</title>
</head>
<body>
<p>wasm test</p>
<script src="module.js"></script>
<script src="wasm_test.js"></script>
</body>
</html>
Loading

0 comments on commit 1df1404

Please sign in to comment.