Code Monkey home page Code Monkey logo

jernejhabjan / trumpdefense2020 Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 1.92 GB

Visual representation of RTS game, supported by deep reinforcement learning algorithm Alpha Zero written in python.

Home Page: https://jernejhabjan.github.io/TrumpDefense2020/

License: MIT License

C++ 94.14% C# 3.29% Shell 2.57%
game game-development monte-carlo-tree-search rts-game real-time-strategy artificial-intelligence alpha-zero reinforcement-learning deep-learning neural-network

trumpdefense2020's Introduction

license

Trump Defense 2020

Author: Jernej Habjan

Title:

  • Učenje realno-časovne strateške igre z uporabo globokega spodbujevalnega učenja
  • Teaching of real-time strategy game using deep reinforcement learning

Versions

#Navigation

Quick overview

Visual representation of RTS game, supported by deep reinforcement learning algorithm Alpha Zero written in python.

Features:

  • Keyboard, mouse camera movement
  • Minimap with optional Fog of War
  • Unit creation
  • Building placement
  • Resource mining
  • Attacking
  • Unit control (control groups)
  • Support for online play
  • Day-night cycle

Startup Guide

Visual Studio

install Visual Studio

  • install "Windows 8.1 sdk"
  • install "Windows 10 sdk (10.0.15063.0)"

Unreal Engine

  • install unreal engine from Epic Launcher or download source from GitHub
  • install VaRest plugin for engine
  • install Kantan Charts plugin for engine
  • if source code engine has been downloaded, you have to copy plugins that are downloaded in Epic Launcher engine and paste them in source code one in Plugins folder

Python

Python 3.6

  • Download and install python 3.6 for plugin UnrealEnginePython in

C:\Program Files\Python36

  • Add it to environmental path

Anaconda

Install anaconda with python 3.6 -- make sure its 64 bit if using 64 bit windows

  • Install it in:

C:\ProgramData\Anaconda3

  • add this path under environmental variables folder

PyTorch

Install Python dev environment https://developer.nvidia.com/how-to-cuda-python

type this in anaconda prompt with admin rights

conda update conda
conda install numba
conda install cudatoolkit
conda install -c peterjc123 pytorch cuda90 

TensorFlow and CUDA

Install cuda:

  • From programs disk install these files in this order:
  • cuda_9.0.176_win10
  • cuda_9.0.176.1_windows
  • cuda_9.0.176.2_windows
  • cuda_9.0.176.3_windows
  • Extract this folder and add it to Cuda path to corresponding folders:
    • cudnn-9.0-windows10-x64-v7.1

vertify cuda installation:

  • nvcc --version

  • make sure its added to env variables:

- C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
- C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp

TensorFlow Gpu

  • Todo - check if i can only import whole conda environment from below tutorial
  • Install tensorflow in pycharm and not from conda cmd (launch it in admin)
  • Interpreter-> check "Use conda package manager button" on the right,
  • add package -> tensorflow-gpu, tensorflow, tensorboard, keras 2.13 - version is important!

Graphviz and pydot:

conda install graphviz
conda install pydot

Download Graphviz executable from Here

Add path to environmental variables and !important! restart Pycharm

C:\Program Files (x86)\Graphviz2.38\bin

Conda export

to export form conda cmd

conda list --explicit > requirements.txt

to install on other machine

conda create --name myenv --file requirements.txt
activate myenv

Requirements are in _Files folder as requirements.txt

Python Alpha Zero algorithm

Defining actions

actions = ["idle", "up", "down", "right", "left", "mine_resources", "return_resources", "attack", "find_enemy", "npc", "rifle_infantry", "town_hall", "barracks", "sentry", "mining_shack", "continue_building"]

That sums up to 16 actions

Defining game rules:

  • Grid of size 8x8,
  • Maximum 1 unit per field.
  • Units for player 1 are defined with positive numbers (1, 2, 3, 4, 5, 6...) where increased number doesn't mean nothing, but every unit is encoded with one of these numbers,
  • Units for player -1 are defined with negative numbers (-1, -2, -3, -4, -5, -6...) where increased number doesn't mean nothing, but every unit is encoded with one of these numbers,
  • Neutral units (minerals) are encoded with small positive integer (0.0001)
  • Empty fields are represented with number 0

Defining win Conditions

1. Create 3 builders:

Point is for algorithm to learn to select town hall and execute action 'npc' before opponent does Actions:

actions = ["idle", "up", "down", "right", "left", "npc"]

Action sequence:

npc
npc
npc

2. Pick up minerals:

Neural network must select town hall, execute action 'npc' to create workers and individually move them towards minerals and pick minerals up Actions:

actions = ["idle", "up", "down", "right", "left", "mine_resources"]

Action sequence:

npc
(while not at minerals)
    move (in apropriate direction)
gather_resources

3. Return minerals:

Player would have to successfully return picked up minerals to resource drain like Town Hall or Mineral Mine. Actions:

actions = ["idle", "up", "down", "right", "left", "mine_resources", "return_resources"]

Action sequence:

npc
(while not at minerals)
    move (in apropriate direction)
gather_resources
(while not at resource drain)
    move (in apropriate direction)
return_resources

4. Build barracks (0 initial money):

Player receives 1 TownHall and 1 NPC at start with 0 money and has to gather enough resources to build barracks. Actions:

actions = ["idle", "up", "down", "right", "left", "mine_resources", "return_resources", "barracks", "continue_building"]

Action sequence:

(while not enough minerals for barracks)
    (while not at minerals)
        move (in apropriate direction)
    gather_resources
    (while not at resource drain)
        move (in apropriate direction)
    return_resources
barracks
(while barracks not built)
    continue_building

5. Gather 1000 minerals:

Point is to set timeout to lower number, which would force player to build economy (building new workers) while gathering minerals. It would need to place mining_shack closer to minerals to more efficiently gather minerals. Actions:

actions = ["idle", "up", "down", "right", "left", "mine_resources", "return_resources", "npc", "mining_shack"]

Action sequence:

(while enough minerals)
    npc OR mining_shack
(while not at minerals)
    move (in apropriate direction)
gather_resources
(while not at resource drain)
    move (in apropriate direction)
return_resources

4. Build Rifle unit from Barracks (0 initial money):

Player receives 1 TownHall and 1 NPC at start with 0 money and has to gather enough resources to build Barracks and from it Rifle unit. Actions:

actions = ["idle", "up", "down", "right", "left", "mine_resources", "return_resources", "rifle_infantry", "barracks", "continue_building"]

Action sequence:

(while not enough minerals for barracks)
    (while not at minerals)
        move (in apropriate direction)
    gather_resources
    (while not at resource drain)
        move (in apropriate direction)
    return_resources
barracks
(while barracks not built)
    continue_building
(repeat step for gathering minerals until enough for Rifle unit)
rifle_unit

4. Destroy enemy (0 initial money):

Player receives 1 TownHall and 1 NPC at start with 0 money and has to gather enough resources to build Barracks and from it Rifle unit. Then has to move rifle unit towards enemy and with it keep attacking enemy units until they are destroyed. Actions:

actions = ["idle", "up", "down", "right", "left", "mine_resources", "return_resources", "attack", "find_enemy", "npc", "rifle_infantry", "barracks", "continue_building"]

Action sequence:

(while not enough minerals for barracks)
    (while not at minerals)
        move (in apropriate direction)
    gather_resources
    (while not at resource drain)
        move (in apropriate direction)
    return_resources
barracks
(while barracks not built)
    continue_building
(repeat step for gathering minerals until enough for Rifle unit)
rifle_unit
(while not at enemy)
    move (in apropriate direction)
(while enemy is alive)
    find_enemy
    (while found enemy is alive)
        attack

Publishing

Steam Api

  • Steam API now works only when publishing using "debug" or "development" option and not "shipping"!

Additional packaging material

  • Make sure you don't forget to add hardware cursors to packaged game.

Setup

  • If source engine is not on disk
    • download source
    • run Setup.bat
    • run GenerateProjectFiles.bat
  • Switch project version to source engine
  • Generate solution
  • Open UE4 solution
    • Development editor - win64 build to see if there are any errors
    • close solution

Client game

  • Open project normally in editor using source engine code as version
    • package project normally in win64

Dedicated server

Build dedicated server

  • Regenerate visual studio project
  • Open solution
    • build using development server option to build dedicated server
    • close solution
  • Copy files "Server" from TD2020/Binaries/WIn64/ (all 4) to Publish/TD2020/Binaries/Win64/
  • Create shortcut of server and add at the end -log with prefix space

Port forwarding and firewall

Fix port forwarding on your router

  • Ue4

    • ip - ip of computer (local)
    • 27015 - internal port
    • 27015 - external port
    • protocol both
  • Steam

    • ip - ip of computer (local)
    • 7777 - internal port
    • 7777 - external port
    • protocol both

Windows firewall - navigate to advanced settings-inbound rules - new rule - port - make 4 combinations - udp and tcp for both ue4 and steam

Check server availability

  • Steam - View -Servers- Lan and internet
  • If server is visible on lan but not on internet - check port forwarding - TODO - HAVEN'T SOLVED THIS YET
  • Open game using:
open 127.0.0.1:7777

Optional Build using Unreal Frontend

It's located in

UE4EngineSourceCode/engine/binaries/win64/UnrealFrontend.exe

  • if you don't have it - visual studio - class view - unreal frontend - right click and build, and then you can access it

  • open UnrealFrontend.exe

  • add custom Launch profile:

    • Project - browse to your project and select Uproject File
  • Do you wish to build -try without , but if errors - yes - in development

  • Cook - by the book

    • windows server
    • select en at the bottom
  • Cooked maps show all - check all

  • package - don't

  • deploy - don't

  • rename it on top:

  • close this and click on newly created "launch profile"

  • if errors when launching, Run it as build, or not...

Add .dll libraries

Add python36.dll (64 - bit) to

YourProject/Publish/WindowsNoEditor/TD2020/Binaries/Win64/

Run tensorboard

cd C:\Users\Jernej\venv\Scripts tensorboard --logdir=C:\TrumpDefense2020\TD2020\Content\Scripts\td2020\models\logsTD2020NNet

Sources:

Plugins used

Repositories used

Video tutorials followed

License

MIT License

Copyright (c) 2018 Jernej Habjan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

trumpdefense2020's People

Contributors

jernejhabjan avatar jhabjanmxp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

amjadtbssm

trumpdefense2020's Issues

Reworking widget display and display for clients

STYLING

  • Remove instant build buttons (buildings, infantry, sentry)
  • Remove cancel button from infantry action list
  • Make action / building / current action / infantry button smaller from 128 to 64
  • Join stats display for single unit to display in single block (name, image and image/progression always, but stats like damage, range, cooldown, personal name, stamina occupants in extra view)
  • Make border image for both races that will wrap widgets and set their background and make same for minerals on top and menu
  • Make menu button with icon as computer
  • Change build time for rifle and bow infantry
  • Change attack icon - this one is all grayed out
  • Fix Selection buttons - icons are not displaying correctly - they are all wrapped and maybe clipping
  • Remove decals that are shown later on minimap
  • Add squad groups as buttons that indicate how many units are selected, portrait and shortcut to select that group
  • Fix functions in commander to properly display and set groups
  • Resize all icons on 128x128

OPTIONAL

  • Fix cancel button on current action list - when clicking cancel from rally on building it doesn't return correct list
  • Fix cancel button on building list (when showing building list it doesn't return to action list
  • View frustrum on minimap is incorrectly displayed when panning
  • Move Create widgets from commander to player controller
  • Display building grid tiles with camera rotation - now every grid is rotated as camera is

Garbage collection on begin training

garbage collect and free ram when executing threaded "onBeginTraining" in get_action - tried gc.collect, del, = None, gc.autocollect, clear_session, sess.close...
try these actions in "onJsonInput"

Check actions ue4 and pygame

check if actions returned to ue4 are the same as are returned in pygame. because as far as i have seen, npcs are only walking in ue4 and not gathering

(also see minerals issue)

Implement Save Game

SaveGame:

Class that retrieves this data - GS_MyGS
SaveGame -> SG_NewSaveGame

Players{
	money: ___
	race: ___
	startPos: ____
	minimap_texture/state - light gray areas
	
	characters{
		health,
		position,
		Stamina
		currentAction{
			OrderType,
	
			targetLocation,
			
			AIState,
			OccupationType,
		}
	}
	buildings{
		health,
		position,
	}
	
	constrProxy{
		displayMesh
		workTimeSpent
		builtClass,
		InstaPay,
		goldSpent
		
	}
	
	
	currentlyProducingUnits -array of classes to build

},

otherObject{
	minerals{
		1: {
			position
			remaining resources
			
		}
	}

},

Game{
	timeRemaining: ____
	IngameTime: ____
	gameSpeed: ___
	timeUnit: ___
	enableStamina,
	EnableCriticalStamina
	AutomaticallyCheckJob
	
}	

Build warnings

  • UATHelper: Packaging (Windows (64-bit)): C:\2018-08-04 16-32\TrumpDefense2020\TD2020\Source\TD2020\Private\Camera\CameraPawnController.cpp(42): warning C4458: declaration of 'SelectableObjectsEnum' hides class member
  • UATHelper: Packaging (Windows (64-bit)): C:\2018-08-04 16-32\TrumpDefense2020\TD2020\Source\TD2020\Public\Camera\CameraPawnController.h(81): note: see declaration of 'ACameraPawnController::SelectableObjectsEnum'

ai communication coordinate system

maybe rotate coord systems up, down, left, right orders
check if for loop is runing in same order as the one in pytho -> x+1, y-1, x, y-1....

Release 1 bugs

ue4 issues:

  • Autodetect graphical settings on first launch - if no savegame for example
  • Some meshes are without textures - rocks, characters etc
  • Reduce package size - number of weapons textures and characters for faster compiling
  • Remove starter content folder and contents that are not used
  • Fix map icons in lobby chooser
  • make map browser for maps with max N number of players that we select in Host game - only these maps must be shown
  • Rename label above host game and join game to Matchmaking
  • Fix avatar icons for player icons
  • Switch mesh for town center and textures
  • Create countdown timer for maps that was set in menu - if not set - display date and time
  • Fix date - it says "2,018" instead of 2018
  • Create match speed - it can be changed in singleplayer, but in multiplayer only for development - maybe include cmd command
  • Fix minimap its black
  • Navigation for characters is still bad when right clicking
    • Its aborted quite often
  • Rifle units dont attack other actor when you assign them other actor to attack
  • When deselecting all actors, action bar like "move,stop,halt,gather,build" is still shown
    • This widget is wrongly displayed - its not vertically joined to top but it has small space in between
  • When creating new building with npc, auto assign this npc to build this building
  • implement save, load, restart which is shown only in singleplayer games - not only for campaign - but if PlayerCntrollers == 1 - you can save, load, restart
    • Implement restart button in ingame menu, which reopens this level
  • Go to score screen opens main menu and shows widget - maybe with parameters, maybe with savegame... dunno - it also may only show widget on top of paused game and after reviewing game it opens main menu
  • create rally command for buildings when left clicking on icon
  • Health for construction proxy shows 100/60 for example construction office
  • Icon for construction proxy is shown as Icon Apartment
  • Make icon for construction proxy more grayed out - tint to gray
  • For occupants / miners / builders adjust coloring - make yellow for 0-40%, green for 40 to like 70 and then red
  • Stamina is shown red when its 100% - this is wrong
  • Enable stamina in campaign (in certain maps) and or add parameter for host games
  • Remove all annoying print strings
  • Make Skin for gui like sc2 for protoss zerg terran (on top and bottom
  • Fix displaying resources in ingame widget
  • Main menu button is dislocated in game - you have to click below it to register
  • Also resources arent displayed in resources graph
  • Swords still cause damage even if not equipped - they should only cause damage to enemy actors when equipped or if we attacked our own
  • Attack move command doesnt work when clicking on button and on ground
  • Gather ommand doesnt work when clicking on button and on ground
  • Remove halt command
  • Switch game speed of 0 to "Paused"
  • Use game speed for build time and unit creation time
  • Fix unit creation time so its not instant
  • right click on minimap doesnt work still- this is optional
  • Fix savegame file for first time game launch - it doesnt set player correctly (try deleting save file for replication)
    Connecting Ue4 with python:
  • Possible plugin
  • Fix mouse cursor
  • Multiple mouse select is broken if started game from menu - for example single player, but works if started directly in TDTestMap
  • Implement attack move command for actor to be seeking attack actor when he is moving to location
  • fix cursor change if hovering over widget
  • attack cursor has right offset for 0.5 and 0.5 but select ones are broken
  • Fix low or critical stamina when executing other actions - it gets buggy

Statistics and stats widget

  • Add dropdown in viewport, that will display stats widget when clicked with animation

STATS WIDGET CONTENT:

  • None - displaying none
  • resource collection rate graph
  • Graphs like army value, workers, resources sum
  • Resources which displays resources and population for all players
  • Current units with number
  • NPC professions (10 Builders, 9 gatherers...) and gather income per minute
  • Current structures
  • Resources spent on NPC, units, buildings, upgrades
  • Units killed, workers killed, structures razed
  • Current production
  • Average unspent resources
  • Build order as grid (Time built, icon, unit name)
  • Action order as grid (Time issued, Action name, description) - like "1:12 | construct | NPC construct Apartment at 100,100,0" or "0:45 | attack | Bowman attack Rifleman at 100,100,0"

SAVING STATISTICS:

  • At end game save statistics on hard drive to be visible later

Release 2 bugs and feature requests

  • mouse cursors are not avaliable on remote machine - set path
  • nared tko da host mora izbrat map preden lahko klikne start session
  • checki če je kje v c++ classih sqrt negative or 0... ker skoz outputa za tem k naloadam mapo v output log
  • LogScriptCore: Warning: Script Msg: Attempt to take Sqrt() of negative number - returning 0.
  • ampak to sam v mp - ko server travelaš iz lobbyja
  • f10 še ne dela
  • Fix cursors - LogHardwareCursor: Error: Failed to load cursor '../../../TD2020/Content/TD2020/Textures/Cursors/AliensCursor'.

RTS Character RtsResourceSource error

=== Handled ensure: ===

Ensure condition failed: Component->HasBegunPlay() [File:D:\Build++UE4+Release-4.19+Compile\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp] [Line: 3129]
Failed to route BeginPlay (RTSResourceSourceComponent /Game/TD2020/Maps/MainMenu.MainMenu:PersistentLevel.Resource_Granite_535.RTSResourceSource)
Stack:
[Callstack] TD2020.exe!FWindowsPlatformStackWalk::StackWalkAndDump() []
[Callstack] TD2020.exe!FDebug::EnsureFailed() []
[Callstack] TD2020.exe!FDebug::OptionallyLogFormattedEnsureMessageReturningFalse() []
[Callstack] TD2020.exe!AActor::BeginPlay() []
[Callstack] TD2020.exe!ARTSCharacter::BeginPlay() [c:\2018-08-04 16-32\trumpdefense2020\td2020\plugins\ue4-rts\source\rts\plugins\rtsplugin\source\rtsplugin\private\rtscharacter.cpp:31]
[Callstack] TD2020.exe!AActor::DispatchBeginPlay() []
[Callstack] TD2020.exe!AWorldSettings::NotifyBeginPlay() []
[Callstack] TD2020.exe!AGameStateBase::HandleBeginPlay() []
[Callstack] TD2020.exe!UWorld::BeginPlay() []
[Callstack] TD2020.exe!UEngine::LoadMap() []
[Callstack] TD2020.exe!UEngine::Browse() []
[Callstack] TD2020.exe!UGameInstance::StartGameInstance() []
[Callstack] TD2020.exe!FEngineLoop::Init() []
[Callstack] TD2020.exe!GuardedMain() []
[Callstack] TD2020.exe!GuardedMainWrapper() []
[Callstack] TD2020.exe!WinMain() []
[Callstack] TD2020.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283]
[Callstack] KERNEL32.DLL!UnknownFunction []
[Callstack] ntdll.dll!UnknownFunction []

PlayerResourcesComponent nullptr exception

Describe the bug
PlayerResourcesComponent member is set in the constructor of the ARTSPlayerController and gets dereferenced before hitting void ARTSPlayerController::BeginPlay() in file
TrumpDefense2020\TD2020\Plugins\RealTimeStrategy\Source\RealTimeStrategy\Private\RTSPlayerController.cpp

To Reproduce
Steps to reproduce the behavior:

  1. compile project
  2. run in viewport
  3. observe crash

Expected behavior
It shouldn't crash

Screenshots
N/A

Desktop (please complete the following information):

Additional context
When you run the project from visual studio and hit the run in viewport preview mode in UE UI, you can set a breakpoint in the ARTSPlayerController constructor.
This allows you to set another breakpoint when PlayerResourcesComponent variable changes (Debug-> New Breakpoint -> Data Breakpoint...: 4 bytes)
This leads to a breakpoint in vcruntime140.dll!memcpy() Line 244 and if you download the debug symbols you'll find the code where it breaks is this

MoveSmall8::
        mov     rcx, qword ptr [rdx]    ; get eight bytes from source
        mov     [rax], rcx              ; write eight bytes to destination
        ret <--

with the following callstack

>	vcruntime140.dll!memcpy() Line 244	Unknown
 	UE4Editor-Engine.dll!00007ffdf52c0913()	Unknown
 	UE4Editor-Engine.dll!00007ffdf52c0a9a()	Unknown
 	UE4Editor-CoreUObject.dll!00007ffdf8dea65c()	Unknown
 	UE4Editor-CoreUObject.dll!00007ffdf8df3518()	Unknown
 	UE4Editor-CoreUObject.dll!00007ffdf8dbf36f()	Unknown
 	UE4Editor-CoreUObject.dll!00007ffdf8e09887()	Unknown
 	UE4Editor-Engine.dll!00007ffdf5942726()	Unknown
 	UE4Editor-Engine.dll!00007ffdf5943067()	Unknown
 	UE4Editor-Engine.dll!00007ffdf56fa173()	Unknown
 	UE4Editor-Engine.dll!00007ffdf56f9f9a()	Unknown
 	UE4Editor-Engine.dll!00007ffdf56e39aa()	Unknown
 	UE4Editor-Engine.dll!00007ffdf5944325()	Unknown
 	UE4Editor-Engine.dll!00007ffdf5943c8c()	Unknown
 	UE4Editor-Engine.dll!00007ffdf56fc0c5()	Unknown
 	UE4Editor-UnrealEd.dll!00007ffdf377ac89()	Unknown
 	UE4Editor-UnrealEd.dll!00007ffdf379b350()	Unknown
 	UE4Editor-UnrealEd.dll!00007ffdf37b92e6()	Unknown
 	UE4Editor-UnrealEd.dll!00007ffdf31b1891()	Unknown
 	UE4Editor-UnrealEd.dll!00007ffdf3ad2346()	Unknown
 	UE4Editor.exe!00007ff7966c6225()	Unknown
 	UE4Editor.exe!00007ff7966d596c()	Unknown
 	UE4Editor.exe!00007ff7966e48aa()	Unknown
 	UE4Editor.exe!00007ff7966e659a()	Unknown
 	kernel32.dll!00007ffe4c697bd4()	Unknown
 	ntdll.dll!00007ffe4d7ace51()	Unknown

this issue could be entirely due to ue4-rts but I thought checking with you first as it seems rather easy to incour into and it seems weird no one experienced it before.

I think it could be due to the fact that PlayerResourcesComponent gets garbage collected by UE as it's not used but that's just a wild guess based on what I read from other similar issues

TBH while compiling this issue I realized this specific commit was fiddling with something around resources so that could be the culprit... npruehs/ue4-rts@fdcb8ae
Anyhow it would be great knowing what's the hash of ue4-rts which is needed to make the project work

P.S. awesome project BTW, very inspiring. Keep it up!

Main menu, Lobby and game seaching

MMR:

  • Matchmaking using your MMR as base point and reward you later for winning or punish for losing

DISPLAYING GAMES:

  • Display grid menu for browsing open lobbies that displays map avatar, map name, game mode (1v1, 2v2, FFA), players in lobby

PERSONAL:

  • Make User widget, that encapsulates user data with profile picture, name and MMR
  • Add widget to be clicked on in menu and when in lobby

NUM PLAYERS:

  • Make sure that Player controller recieves right amount of requests to spawn players

LOBBY:
Add option to add AI with difficulty that will represent number of simulations being ran each cycle

Remove uneeded modules in TD2020 build

  • "Core",

  • "CoreUObject",

  • "Engine",

  • "InputCore",

  • "RHI",

  • "UMG",

  • "Slate",

  • "SlateCore",

  • "AIModule",

  • "GameplayTasks",

  • "RenderCore",

  • "ShaderCore",

  • "Landscape"

  • Modules used in RTS Plugin

    • "Core",
    • "CoreUObject",
    • "Engine",
    • "InputCore",
    • "AIModule",
    • "UMG",
    • "Slate",
    • "SlateCore",
    • "RHI",
    • "RenderCore",
    • "Landscape"

Game Ai

  • update readme explaining all details about my variant of alpha zero algorithm

  • Nared tko da ce nbena akcija ni valid... Pol ga lah idla algoritm

  • Pri pit za vse mozne akcije nared predict pa naris na pygame top 5 cifr z vrednostmi

  • Arena printing game result -1

  • poglej če se dvakrat ne dodeli zmaga ena in istmu

  • pygame get monitor size in inches and set Canvas Scaled

  • Napis da za idle je pol algo najveckrat obiskov idle vozlisce pa ga je vrnu kot max probabiliyy

  • Make sure you use the latest version of Keras. pip install keras --upgrade

  • Also, this error has been reported here in the keras github: keras-team/keras#3426

  • on linux:

  • sudo apt-get install libhdf5

  • sudo pip install h5py

  • The actual installation of h5py should be done via:

  • $ pip install --no-binary=h5py h5py

  • http://docs.h5py.org/en/latest/build.html

  • Probi packagat tensrflow ue4 pa se umadva plugina na novmu projectu third person pa mu napis na git ce bojo ksni errorji- done - jih ni - probi v temu projectu dat še install pypip un h5py shit

  • removed state idle from all actions

  • dj testi vse te funkcije manually pls... sam zalaufi pit pa naštimi velk timeout

Define game in python

  • Define grid
  • Define units with inheritance (for now only ranged)
  • Import csv reader / json reader (depending on Unreal engine datatable export settings)
  • Read stats from exported datatable as CSV into python
  • Set appropriate stats (dmg, cost, range...)
  • Define actions - look at MicroRTS (move actions for left right up down...)
  • Define which actors can be spawned by which building
  • Define tech tree

4.22 build failed

Hi, I get these errors on 4.22. Can you help me out?

Severity	Code	Description	Project	File	Line	Suppression State
Warning		Modules must specify an explicit precompiled header (eg. PrivatePCHHeaderFile = "TD2020.h") from UE 4.21 onwards.	TD2020	C:\Users\sam\Dev\TrumpDefense2020\TD2020 4.22\Source\TD2020\TD2020.Build.cs	1	
Error		Could not find definition for module 'ShaderCore' (referenced via Target -> TD2020.Build.cs)	TD2020	C:\Users\sam\Dev\TrumpDefense2020\TD2020 4.22\Intermediate\ProjectFiles\UnrealBuildTool	1	
Error	MSB3075	The command ""C:\Program Files\Epic Games\UE_4.22\Engine\Build\BatchFiles\Build.bat" TD2020Editor Win64 Development -Project="C:\Users\sam\Dev\TrumpDefense2020\TD2020 4.22\TD2020.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.	TD2020	C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets	44	

Reducing plugin usage

Reparent plugin for RTS, switch content like decorators, tasks and switch structs and enums

Fog of war actor colliding with sky sphere

Minerals not having appropriate team name

Minerals should have the same team name as town hall near it in ue4.
It should have same team name as in pygame, but its reversed, because of random assignment of mineral patches to players in "getWorldInfo" in cmpTensorflow.

Because when i try to mine minerals, npc goes to opposite minerals in diagonal.

TD2020 campaign

TD2020 Campaign:

  • Map 1: Intro cinematic
  • Map 2: (playable 1) Walk with trumpko to somewhere, as where trumpko has AK47
  • Map 3: (playable 2) Simple goal to gather 1000 minerals, make barracks and create 3 units
  • Map 4: (playable 3) Defend 3 waves of attacks
  • Map 5: Enemy introduction cinematic
  • Map 6: (playable 4) 1v1 battle on friendly terrain
  • Map 7: (playable 5) 1v1 battle at night - many spotlights etc - house lights
  • Map 8: (playable 6) 1v1 battle with random events (sandstorm etc)
  • Map 10: Outro cinematic - wall built

Code preparation for diploma thesis

  • 08: Map building of buildings in ue4
  • 09: Todo: fix running ue4 python script tensorflow errors - connected to grid
  • 10: Helping @home
  • 11: Helping @home
  • 12: Helping @home
  • 13: Helping @home
    Create widget to display remaining time and buttons that will order computer ai actions -> Human player component
  • 14: Link all other actions and test them via buttons up down left right, mine....
    ################
  • 15: Time to polish actions linking in ue5
  • 16: Time to polish actions linking in ue4
    Email mentors about completed visualizations
  • 17: Try building model and make sure you can run this script on work laptop to build model @work over night
  • 18: Figure out formula for destroying actors over time and how to prevent both players getting destroyed at same time
  • 19: implement formula for destroying actors (even if it destroys both players)
  • 20: Helping @home
    Destroying actors with formula with their healing - implement healing and test it
  • 21: General overlook through scirpts and fix possible errors/ bugs
    Possible email to mentors about formula
    ################
  • 22: Day off
  • 23: Test building model and check its results w and w/o one hot encoding
    Leave computer at work over night to build model to test if building of model actually works
  • 24: Wrap "badly built model" in ue4 and run from ue4 with possibility of packaging
  • 25: Waste whole day with trying to package project
  • 26: Wrap py code up, cleanup comments, document everything
  • 27: Helping @home
    Learning model configs, excluding idle state etc
  • 28: Learning model with other configs, encodings, testing results in pygame
    Possible change of timeout formula to make it more strict..
    Document changes made by changing parameters
    Possible NN model change
    ################
  • 29: Day off
    Take a look at results and email mentors
  • 30: Wrapping of code and changing model according to mentors' proposition
  • 31: Changing of code accoring to proposition
  • 1: Leave computer at work over night to build model with preset config of iterations, sims etc.
    Another round of code cleanup and finalizing connection to ue4
    Document ue4 connection and wrap it in module
  • 2: Summing possible errors in prebuilt model
  • 3: Helping @home
  • 4: More error debugging
    ################
  • 5: Day off
    Leave computer at work over night with different config
  • 6: Leave computer at work over night with fixed config and one hot encoding
  • 7: Leave computer at work over night with fixed config and w/o one hot encoding
  • 8: Evaluate best model in ue4 and start writing diploma thesis

Release 1 bugs and feature requests

  • Minimap click on client
  • Bind day night cycle on game speed
  • Build buildings without construction office
  • Check ros and roc in master commander on begin play
  • Fog of War post processing volume fix
  • Npc stuck after assigning construction when collecting minerals
  • Chat T button doesnt work in game
  • Save load - save photo as primitive and not as reference for map photo
  • load game pri pawn computerju ne deleta buildingu ampak nove čez nalima
    • mogoče select all actors dela za pawn master computerja za oba - da nazaj dobi server in client actorje

Client widgets

CLIENT:

  • Fix clicking widgets on client - cannot press buttons like "place building" (some like stop order is working, so maybe ghost building must not set correctly)
  • Fix changing game speed from client
  • Fix left mouse click on client - it messes with pawn teleporting him constantly
  • Fix right click on map for client - command like move by commander is not issued
    MUSIC:
  • Add music - https://goo.gl/vQpaq7

Implementing custom py game in Alpha Zero

create td2020 game with 2d grid as games like othello or connect4 are made:

  • limit number of actors on tile to MAX_NUM_ACOTRS_ON_TILE --- written in grid class
  • attack action - check if actor is in range (actionManager)
  • use ALL ACTIONS dictionary to map actions to numbers or other way around (actionManager)
  • display_obj- make prefix of which team the piece is on board. If pieces of both teams are on same tile, make special suffix.. (Grid)
  • spawn new character in appropriate world - construct_unit (Components)
  • manager game_logic - actions are chosen as many times as current player has actors and action is random (Game)
  • Fix main functions like getNextState, getValidMoves... (Game)
  • create your action input for Human Player (OthelloPlayers)
  • increment health - to cover whole 100% when built to max - same as sc2 - continue building (ActionManager)
  • Fix input size for fit function
  • Fix general model sizes
  • Add layers to model?
  • in file NNet.py - i'm removing last entry in PIS - this may be wrong

Models, Textures, thumbnails

MODEL SIZE AND ROTATION:

  • Change models size to fit same size
  • Rotate models to face towards entrance
  • Change model for Human barracks
  • Map textures on Shack
  • Map textures on Mining shack
  • Make Town center mesh - Similar to White House

Day night cycle NaN

=== Handled ensure: ===
Ensure condition failed: !RotationQuat.ContainsNaN() [File:D:\Build++UE4+Release-4.19+Compile\Sync\Engine\Source\Runtime\Core\Private\Math\UnrealMath.cpp] [Line: 429]
Invalid input to FRotator::Quaternion - generated NaN output: X=-nan(ind) Y=nan Z=-nan(ind) W=-nan(ind)
Stack:
[Callstack] TD2020.exe!FWindowsPlatformStackWalk::StackWalkAndDump() []
[Callstack] TD2020.exe!FDebug::EnsureFailed() []
[Callstack] TD2020.exe!FDebug::OptionallyLogFormattedEnsureMessageReturningFalse() []
[Callstack] TD2020.exe!FRotator::Quaternion() []
[Callstack] TD2020.exe!USceneComponent::MoveComponent() []
[Callstack] TD2020.exe!AActor::SetActorRotation() []
[Callstack] TD2020.exe!ADayNightCycle::Tick() [c:\2018-08-04 16-32\trumpdefense2020\td2020\source\td2020\private\enviroment\daynightcycle.cpp:283]
[Callstack] TD2020.exe!AActor::TickActor() []
[Callstack] TD2020.exe!FActorTickFunction::ExecuteTick() []
[Callstack] TD2020.exe!FTickFunctionTask::DoTask() []
[Callstack] TD2020.exe!TGraphTask::ExecuteTask() []
[Callstack] TD2020.exe!FNamedTaskThread::ProcessTasksNamedThread() []
[Callstack] TD2020.exe!FNamedTaskThread::ProcessTasksUntilQuit() []
[Callstack] TD2020.exe!FTickTaskSequencer::ReleaseTickGroup() []
[Callstack] TD2020.exe!FTickTaskManager::RunTickGroup() []
[Callstack] TD2020.exe!UWorld::RunTickGroup() []
[Callstack] TD2020.exe!UWorld::Tick() []
[Callstack] TD2020.exe!UGameEngine::Tick() []
[Callstack] TD2020.exe!FEngineLoop::Tick() []
[Callstack] TD2020.exe!GuardedMain() []
[Callstack] TD2020.exe!GuardedMainWrapper() []
[Callstack] TD2020.exe!WinMain() []
[Callstack] TD2020.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283]
[Callstack] KERNEL32.DLL!UnknownFunction []
[Callstack] ntdll.dll!UnknownFunction []

if (FMath::IsNaN(SunPitch) || FMath::IsNaN(SunYaw)) {
	if (GEngine)
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Sun Pitch or Sun yaw is nan"));
}
else {
	SunLight->SetActorRotation(FRotator(SunPitch, SunYaw, 0.0f));
}

// call of Sky sphere function
Valid = SkySphere->UpdateSunDirection();

MoonTrajectory();
if (FMath::IsNaN(MoonPitch) || FMath::IsNaN(MoonYaw)) {
	if (GEngine)
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Moon Pitch or Moon yaw is nan"));
}
else {
	MoonLight->SetActorRotation(FRotator(MoonPitch, MoonYaw, 0.0f));
}


FLatentActionInfo LatentInfo = FLatentActionInfo();
LatentInfo.CallbackTarget = this;
if (FMath::IsNaN(MoonPitch) || FMath::IsNaN(MoonYaw)) {
	if (GEngine)
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Moon Pitch or Moon yaw is nan"));
}
else {
	UKismetSystemLibrary::MoveComponentTo(Scene, Scene->GetComponentLocation(), FRotator(MoonPitch, MoonYaw, 0.0f), false, false, 0.0f, true, EMoveComponentAction::Move, LatentInfo);
}
// change material
if (FMath::IsNaN(SunPitch)) {
	if (GEngine)
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Sun Pitch is nan"));
}
else {
	MoonMaterialInstance->SetVectorParameterValue("MoonColor", SkyColor->GetLinearColorValue(UKismetMathLibrary::MapRangeUnclamped(SunPitch, 0.0f, -18.0f, 0.0f, 1.0f)));

}

Steam Api disabled

This is shown as warning when exporting project. This may cause client to crash on computer that doesnt have installed unreal engine.
Links:

Code below that has been generated is causing problems when building project

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;

public class TD2020 : ModuleRules
{
    public TD2020(TargetInfo Target)
    {
        
        MinFilesUsingPrecompiledHeaderOverride = 1;
        bFasterWithoutUnity = true;
        
        PublicDependencyModuleNames.AddRange(
            new string[] { 
                "Core",
                "CoreUObject",
                "Engine",
                "InputCore",
				"AIModule", "GameplayTasks",
                "RHI",
                "UMG", "Slate", "SlateCore"
            }
        );
        
        PublicDependencyModuleNames.AddRange(new string[] { 
            "OnlineSubsystem",
            "OnlineSubsystemUtils"
        });
        
        DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
    }
}

Commands / Idle commands

ISSUING COMMANDS:

  • Prepare functions for each command to be executed from pawn and from AI controller - can be event drive - On order issued
  • For moving units - rework each "move to by commander" to "Issue move command", which will happen on behavior tree
  • Fix rally snapping (last index deletion...) - In function Add Rally on 0_Base
  • Don't show rally for enemy units / buildings
  • Switch mesh for rally on buildings to decals - display decal on last rally

COMMANDS:

  • Stop - when constructed building, killed actor, finishing move command
  • Hold position
  • Move
  • attack - beware attack on ground (if hit actor == Landscape - check for enemy in my range - check this on tick when moving - maybe check in decorator in behavior tree)
  • Gather - when starting to collect minerals
  • Return gather - when returning minerals
  • Build - when starting to build house
  • Halt - stops building

BEHAVIOR TREE:

  • Merge trees into RTS one and keep branches in order - maybe I can move all other trees in Idle.
  • Rework attack, because its not using my animations and projectiles, etc.

PROJECTILES:

  • Reparent projectile to RTS one - maybe problems with collision

CLIENT:

  • Fix rally HUD display to show rallies also on client - maybe doesn't get right rally array

OPTIONAL:

  • Disable stop animation when issuing new command - this causes character to stutter when moving to another location

Components

BUILDINGS:

  • Add Construction component for construction office
  • Add Attack component for defense master
  • Add Production component for army master
  • Add Residential component for Residential master

Remove uneeded plugins

LogPluginManager: Mounting plugin OnlineSubsystemSteam
LogPluginManager: Mounting plugin OnlineSubsystem
LogPluginManager: Mounting plugin OnlineSubsystemUtils
LogPluginManager: Mounting plugin KantanCharts
LogPluginManager: Mounting plugin VaRestPlugin
LogPluginManager: Mounting plugin RTSPlugin
LogPluginManager: Mounting plugin CryptoKeys
LogPluginManager: Mounting plugin DatasmithContent
LogPluginManager: Mounting plugin CharacterAI
LogPluginManager: Mounting plugin LinearTimecode
LogPluginManager: Mounting plugin TcpMessaging
LogPluginManager: Mounting plugin UdpMessaging
LogPluginManager: Mounting plugin OnlineSubsystemNull
LogPluginManager: Mounting plugin ExampleDeviceProfileSelecton

Creating Agent Blueprint

  • Create blueprint that will have access to game state data and can issue commands
  • Spawn agent from viewport - must be independent
  • Spawn agent when playing from lobby and agent is set
  • Retrieve all important variables in this blueprint while in game
  • For start set him to execute random orders in time span
  • Implement build orders
  • Connect Python scripts to this blueprint and communicate with python with functions, pass data, etc.

Logic

  • Fix speed multiplier for commander

  • When spawning from building - actors are not spawned from right position (they are displaced on x axis for like 300)

  • Add Town center, that has ability to return resources to, spawn NPCs- should implement construction and gathering component - look "Components issue"

  • Fix Building collision box function call in master building - generates giant overlaps (cannot place building) and projectiles cannot pass through

  • Fix Building collision with player - it shouldn't prevent from placing building on ground if pawn is there

  • Fix adding to occupancy when right clicking on building, to remove NPC from work place when issued other command
    GAME RULES:

    • Add winning condition, timeout condition, tie
    • Add scoring system for each player for each game and MMR for multiple games.
    • Scoring system includes score, that will be used for AI to evaluate its actions on
  • Fix teammates hitting each other with swords

  • Client - fix lerping because its stuttering with SetActorLocation, without applying Move Input

    • Lerp in MyActor is not the right function that is being used on icon click
  • Fix rally on buildings

  • Delete entity structs

  • use production cost property when building units

Datatables

  • Variables in ue4 can be parameterized - look it up how to set it up with config file
  • Build orders
  • Units stats
  • Building stats
  • Building production avaliability
  • Build times, costs
  • Misc like walk speed
  • Export to csv / json

Fix steam and lan

Maybe errors are because I changed main menu game mode to GM_Gameplay_GM, from main menu gm.

Maybe its because of upgrade to 4.20 ue4.
Check output logs, it shouldnt be so hard to fix

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.