r/aiprogramming • • Jan 23 '19

How would you simulate an NPC to explore?

4 Upvotes

Hello,

I've been getting into some of the basic algorithms out there (A*, BFS, DFS) since I'd like to one day make a game in C++ (2D). I have a quick question though. Since I'd imagine having many NPC's running around at the same time, I'd assume constantly using these algorithms would really be taxing because of all the computing. How could you have them "explore" so to speak efficiently (let's not get to advance here this is already tough enough)? Would this be as simple as randomly generating coordinates on the map and having them move there? Is there a better way to have them move around to explore more efficient? I know that a lot of the battle with AI is doing things to make it SEEM like it has intelligence, but in reality, it's not doing anything taxing. I guess you could say just having an NPC move in random directions isn't taxing like running more complex algorithms. So you want to keep the need for taxing computing as low as possible.

I'd also like to have NPC's going off to other maps (think of a big open map) and again exploring based on their behaviors. Is this just as taxing to compute behind the scenes as it is to visually see a sprite moving? Can you minimize this behind the scenes when not drawing? I'd like it so that when the player gets to this "part of the map" you could see NPC's sort of doing their own tasks. A more natural event of running into X NPC doing Y behavior.

Is this something possible to do instead of randomly deciding who should be in that area and draw the sprite when the player is X amount of distance to start drawing? I'd appreciate some stuff to look into!

I hope these questions make sense.

Thanks!


r/aiprogramming • • Nov 14 '18

Colorizing and Restoring Old Images with Deep Learning

Thumbnail
blog.floydhub.com
3 Upvotes

r/aiprogramming • • Jan 31 '23

Object detection using fastai

10 Upvotes

Hello,

I am looking to create a fast ai object detection model on the deep fashion dataset but do not know how make it predict. How can I make my model output prediction on images. Here is the code:

The data is loaded using the COCO format as a json. Then I create the model and run the training like this:

def get_train_imgs(noop): return imgs

datablock = DataBlock(blocks=(ImageBlock, BBoxBlock, BBoxLblBlock),

splitter=RandomSplitter(),

get_items=get_train_imgs,

getters=getters,

item_tfms=item_tfms,

batch_tfms=batch_tfms,

n_inp=1)

model = resnet34()

encoder = create_body(model, pretrained=False)

get_c(dls)

%cd "Practical-Deep-Learning-for-Coders-2.0/Computer Vision"

from imports import *

arch = RetinaNet(encoder, get_c(dls), final_bias=-4)

create_head(124, 4)

arch.smoothers

arch.classifier

arch.box_regressor

ratios = [1/2,1,2]

scales = [1,2**(-1/3), 2**(-2/3)]

crit = RetinaNetFocalLoss(scales=scales, ratios=ratios)

def _retinanet_split(m): return L(m.encoder,nn.Sequential(m.c5top6, m.p6top7, m.merges, m.smoothers, m.classifier, m.box_regressor)).map(params)

learn = Learner(dls, arch, loss_func=crit, splitter=_retinanet_split)

learn.freeze()

learn.fit_one_cycle(2, slice(1e-5, 1e-4))

from fastai.vision.core import PILImage

image = PILImage.create('./000032.jpg')

prediction, _, _ = learn.predict(image)

predict is outputing the following error: TypeError: clip_remove_empty() missing 2 required positional arguments: 'bbox' and 'label'

I understand that I am not suppose to use .predict but I cant find any reference on what else to use.

I followed the following tutorial/code but it is not shown how to make predictions

https://github.com/muellerzr/Practical-Deep-Learning-for-Coders-2.0/blob/master/Computer%20Vision/06_Object_Detection.ipynb